NextGrid & NextDBGrid








NextGrid .NET

ToolbarItem tutorial

Related Articles:

  • Skill:
  • Version: 1.0.0
  • Author: Bojan Nikolic
  • Created: 2009-07-22
  • Updated: 2009-07-22

1. Introducing

TNxToolbarItem () item type (and all descendants) can be used when user need to set Item's Value by clicking on Buttons. Each TNxToolbarItem can have many Buttons and each Button can have Image (Glyph) and Text.

TNxToolbarItem is Ancestor for following items types:

Descending Items are simply pre-configured for special purpose: Buttons are added, configured and ready to use. If you like, you can insert new, or delete existing Buttons from this pre-configured Item types. For example: We can add Strikethrough button inside TNxFontStyleItem, or to change Buttons order, or to delete Italic button...To more simplify: when you delete all buttons from some of descendants Item types you will get TNxToolbarItem.

2. Adding new TNxToolbarItem

1. Place one TNextInspector component on Form
2. Double click on NextInspector component and Items Editor will be shown
3. Add one TNxTextItem Item for first category

Select this new Item in Items Editor and then click on TNxToolbarItem to add child-item

3. Working with Buttons

Select this new TNxToolbarItem in Editor and you will see inspector for this Item in Object Inspector.

Locate "Buttons" property and click on button beside it. Collection Editor will be shown then.

In Collection Editor you can add, delete buttons and change inspector for each button. You may note that when you work with TNxAlignmentItem, TNxFontStyleItem... some buttons will be here already!

4. Working with Single Button

When Collection Editor is open, you can add, delete or change single Button inspector.

To add new button click on button.

To delete existing button, select button first and then click on button.

To change buttons order, select buton and click on or on

5. Button properties

Each button have next properties:

Table 1: Button properties
Name Type Description
AutoCheck Boolean When is True, button will stay in Checked state when user click on it
Divider Boolean When is True, button will become and it will be painted as Divider.
Checked Boolean Button will be checked. If property Grouped of Item is True, then all other buttons will be unchecked.
Glyph TBitmap Image for button.
Text WideString Text for button. This text will be displayed in Item when user click on this button.

To change Button inspector in run-time, you nee to write something like this:

uses NxPropertyItemClasses;
with NextInspector1.Categories[0].Items[0] as TNxToolbarITem do
  Buttons[0].Checked := True;
  Buttons.Items[1].Text := 'Sample';

6. Keyboard Support

Buttons in TNxToolbarItem can be Checked or Unchecked with using number (1 - 9) keys. If you press key 1, first button will be checked.

When Button have Divider = True, this button will be skipped and next non-divide button will be Checked or Unchecked.

Buttons where AutoCheck = False are ignored, but not skipped.

7. Example: Create Pinned Category

This example require NextInspector version 2.4

In next example we will create one Category Item with "Pin Button" which can be used for locking Expand property of Category.

1. Place one TNextInspector component on Form
2. Open Items Editor and add one TNxToolbarItem as first Category.
3. Set Align property for this Item to taRightJustify.
4. Set AllowAllUp property to True.
5. Set ReadOnly property to False.
6. Open Button Editor and Add one Button. You can place some Pin Glyph inside it.
7. Add few new Child Items inside this Category.
8. Enter next code in OnToolbarClick event of NextInspector:

uses NxPropertyItems, NxPropertyItemClasses;
if Item.Items.Count > 0 then // Item have sub-items?
  with Item as TNxToolbarItem do
    ExpandLock := Buttons[ButtonIndex].Checked;

Was This Article Useful?


2009-09-07 19:07:08

I want buy your product with my MasterCard for Delphi 2009 but I not leave in USA !!! Your register for order no corectli work ~!!!

2009-09-07 19:15:37


You may order by using Master Card from allmost any country. If you still have difficulties, please contact me on email
Only constructive comments, code contributions... will be publishes. Questions, non-official discussion will not be published.