Property Grid comprehensive sample
dim pg as p
dim pg.settings as p
dim pg.def as c
'Here is some additional information:
'(These directives can be put into the property grid definition before the first category).
'1. You can put line breaks in the help text using the \n character
'2. The properties can be shown in categories, or in a flat list
' order=sort --- shows the properties in categories
' order=nosort --- shows the properties in a flat list
'3. For smart fields, you can show the buttons always, or only when the field has focus
' showButtonsAlways=true -- show button even when field does not have focus
' showButtonsAlways=false -- show button only when field has focus
' visualtheme=number - enter a number between 0 and 6
' fontdef=Tahoma,8,i - set the font to Tahoma, 8pt, italic
'6. Size of the help window
' helpheight=120 - sets the height to '120'. You need to experiment to find the value that suits you.
'7. Has help window
'8. Has toolbar - the toolbar appears at the top of the Property Grid and it allows you to toggle between a categorized view and a flat view.
'9 The splitter controls what portion of the Property Grid width is devoted to property labels and what portion is devoted to data values.
' splitter=0.3 -- indicates that 30% of the width is devoted to the labels.
v.Item1 = ""
v.item2 = .t.
v.item3 = ""
v.item3A = ""
v.item4 = "Blue"
v.item5 = ""
v.item6 = .t.
v.item7 = ""
v.item8 = ""
v.item9 = "You can only edit this value using the smart field button"
v.item10 = ""
v.nitem1 = .f.
v.nitem2 = ""
v.nitem3 = ""
v.dblnitem1 = ""
v.dblnitem2 = ""
dim clicktoEdit as c
clicktoEdit = "<Click the smart field to edit>"
dim choices as p
choices.item4 = sortsubstr(a5.Color_Enum(),crlf())
pg.def = <<%str%
help=A standard input. When the user makes a change to this value an event called 'event1' is fired. The Xdialog that hosts this propery Grid will handle the event.
help=A standard checkbox. Notice that you don't need to set the control type - it knows that it should be a checkbox because v.item2 is a logical field. In some cases, if the type does not default to a checkbox, you can force it to be a checkbox with the 'type=checkbox' attribute.
++Combo box 1
help=A standard combo box. Notice that the choices are defined in the Property Grid definition in the 'data' attribute.
++Combo box 2
help=A standard combo box, but notice difference between this and 'Combo box 1'. In this cases the choices are in a variable called 'choices.item4'. We have also set a default value for the field.
++Edit combo box 1
help=Similar to the combo box examples, but the user is free to type in values that are not in the dropdown lists.
^^Category 2 (Only shown if entry in 'Standard input' is blank)
show_category=v.item1 = ""
^^Show/Hide Individual Items
++Show Item 7
help=Item 7 is only shown if this property is checked.
help=The show expression can be any valid Xbasic expression.
++Smart field 1
data=v.item8=ui_get_text("Enter value","Enter value for this property",v.item8)
help=This is a 'smart field'. When the user clicks the button, the code in the 'data' attribute is executed to prompt for the value of the variable.\nNote that in this case the user is free to use the smart field, or type directly into the property grid. In the next example we will show how you can force the user to use the smart field.
++Smart field 2
data=v.item9=ui_get_text("Enter value","Enter value for this property",v.item9)
help=This is a 'smart field'. When the user clicks the button, the code in the 'data' attribute is executed to prompt for the value of the variable.\nNote that in this case the user must use the smart field. They cannot type directly into the property grid. This is done by setting the 'readonly=.t.' attribute.
++Smart field 3
data=v.item10= ui_get_text("Enter value","Enter value for this property",v.item10)
help=This is similar to 'Smart field 2' except that the value in the property is not shown. Instead an instruction is shown. The instruction is shown in bold if the data in variable for this property is not blank. This is done using the 'inputbold=expression' attribute. This provides a visual cue that the user has edited the value.
++Nested item parent
<<Nested property 1
<<Nested property 2
<<<Double Nested property 1
<<<Double Nested property 2
if a_dlg_button = "event1"
a_dlg_button = ""