Downloads Articles Order Sign In
Welcome to Official Berg Software web site. Twelve years with you! All other websites providing Berg Software source code and content are illegal. We will not support users who use services, or buy products from illegal Berg Software websites. more...
  Home  
  News Archive  
  Components  
  Applications  
  Downloads  
  Order  
  Support  
  About  
 
  Components
  GridView
  DBGridView
  PropertiesView
  SheetView
  Comp. Collection
 
  Applications
  Berg Player
  SMS Mara Gateway
  Domain Binocular
 
 
  Support
  Contact Us
  Support forums
  Articles
 
 
 
WORK WITH PROPERTIESVIEW IN RUN TIME Home > Articles > PropertiesView

Working with PropertiesView in Run-time.

Before reading this article, please read fillowing articles first:

Work with PropertiesView in Design-time

Also, we recommend that you become familiar with Item types.

Most important property inside PropertiesView is Categories property. This property handle Categories Items. Each Category Item also have own Child Items, each Chid Item can have onw Items and so on.

PropertiesView
Categories: TPropertyItems
  Item[0]: TCustomItem
  Items: TPropertyItems
    Item[0]: TCustomItem
    Item[1]: TCustomItem
    Add ...
  Item[1]: TCustomItem
  Item[2]: TCustomItem
  Add() ...

First we need to add categories (top level items). For example:

{ This 2 lines of code will add 2 top level items, and set captions }
with PropertiesView1 do
begin
Categories.Add(TTextualItem, 'First Category');
Categories.Add(TTextualItem, 'Next Category'); end;

After that we can start with adding child items into these 2 categories.

Let we add one new item named "Background Color" inside first category.

For color properties is best to use TColorItem item . With using this item User will have drop-down color picker for easy color choosing.

with PropertiesView1.Categories[0] do
begin 
{ next line will add new item TColorItem, set caption and value } Items.Add(TColorItem, 'Background Color', '#ff0ff');
end;

This code can be also writed as:

PropertiesView1.Categories.Item[0].Items.Add(TColorItem, 'Background Color', '#ff0ff');

or very short:

PropertiesView1.Categories[0].Add(TColorItem, 'Background Color', '#ff0ff');

If we need to set some Item's property, we can write:

PropertiesView1.Categories[0].Items[0].Caption := 'My Item';

But, if you need access to some TColorItem specific property simply use typecasting:

TColorItem(Items[0]).ColorKind = ckWeb; // set color format to web color format

Now we can add one more item named "Border Width". This item will accept only number and here we will use TSpinItem for item.

It will be great that user can have possibility to choose units for border width, such as "px", "pt", "%"...To enable this we will show small drop-down list beside property value. To show this list you need to simply turn on ioSuffix flag in Item Options property.

with PropertiesView1.Categories[0] do
begin
{ add new item, set caption and value } Items.Add(TSpinItem, 'Border Width', '0'); Items[1].Options := [ioSuffixes]; // this will show small drop-down list Items[1].SuffixValue = 'px'; // this will set initial suffix value { let's add few items into suffixes list. This is a simple TStrings property } with Items[1].Suffixes do begin Add('px'); Add('pt'); Add('%'); Add('inch'); Add('cm'); end;
end;

If we want to get value of property merged with SuffixValue we can simply use:

MyStringVariable = PropertiesView1.Categories[0].Items[1].FullText;

Caption and Value of property can be changed in any time by setting Caption and Value property:

PropertiesView1.Categories[0].Items[1].Caption = 'Border Line Width';
PropertiesView1.Categories[0].Items[1].Value = '3';

If some Item have name, you can use ItemByName property of Parent Item to access this Item:

Categories[0].Items[0].Name = 'test';
ShowMessage(Categories[0].ItemByName['test']);

 

 
Copyright © BergSoftware 1996 - 2009. All rights reserved.Contact Us.