Properties Grid Control | CodeGuru

Properties Grid Control

This article contains the detail documentation of XPropertiesWnd Control described in A Set of 2 ActveX controls Properties Grid Control looks exactly like property window from Visual Basic and has more features. It has two columns. The first column contains the name of a property and the second contains the property’s value. The following are […]

Written By
CodeGuru Staff
CodeGuru Staff
Jan 10, 1999
8 minute read
CodeGuru content and product recommendations are editorially independent. We may make money when you click on links to our partners. Learn More

This article contains the detail documentation of XPropertiesWnd Control described
in A Set of 2 ActveX controls

Properties Grid Control looks exactly like property window from Visual Basic and has
more features. It has two columns. The first column contains the name of a property and the second contains the property’s value. The following
are the properties, methods and events of the Control:


Properties












































Type


Name


Specification


OLE_COLOR


BackColor


Change the background color of this control


BSTR


PagesAndItems


Store all elements from this grid into a template form. It is usefull when user want to load more pages and items without flickering.


Boolean


ToolTips


If the value of one property is not entirely visible, you can activate tooltips with this property.


Boolean


FirstPageHasCaption


Has effect only if control has one page. In that case if this is FALSE the page hasn’t a caption bar.



Boolean


AsFloor


Set the style of the contained xFloorWnd Control to be as floor or page.


IFontDisp*


ItemFont


Set the font for all properties.


IFontDisp*


Font


Set the font for the caption pages or for group property


boolean


ResizeFirstColumn


true –

means that you can resize the column name of grid, and false otherwise

boolean


Animation


true –

this means that if we are more then one page, when you select other page then the current one this will be activated using animation. false – the selected page will be activated
instantly

Methods























































































































































Name


Specification


short

AddPage(BSTR lpszPageName)

this method adds a new page called lpszPageName into the control and returns the index of this page.


boolean

DeletePage(short nIndexPage)

This method deletes the page with the index nIndexPage.Returns true if the page was deleted successfully and false otherwise.


long

GetPagesCount()

returns the number of pages from xPropertiesWnd Control.


BSTR

GetPageName(short nIndexPage)

returns the name for the page with the index nIndexPage and Null if error


short

GetPage(BSTR lpszPageName)

returns the index of the page with the name lpszPageName. If there is no page with this name it returns –1


void

ActivatePage(short nIndexPage)

activates the page with the index nIndexPage


short

InsertProperty(short nIndexPage, short nIndexProperty, BSTR lpszPropertyName, BSTR lpszPropertyAs, short lpszProperyType)

inserts a new property with name lpszPropertyName. In this case, lpszPropertyName cannot be in the path form. For the other parameters see the AddProperty method. If nIndexProperty is –1 it means that the adding will be done at the end of the page.


boolean

DeleteProperty(short nIndexPage, short nIndexProperty)

deletes the property with the index nIndexProperty from nIndexPage page. Returns true if the deletion has done successfully


BSTR

GetPropertyName(short nIndexPage, short nIndexProperty)

returns the name of property from nIndexPage page, at nIndexProperty position or Null if no property is found.


short

GetPropertyType(short nIndexPage, short nIndexProperty)

f the property from page nIndexPage at nIndexProperty position is enable, the function will return 0. Else, the returned values will be 1 or 2. 1 for grayed property and 2 for black property


void

SetPropertyType(short nIndexPage, short nIndexProperty, short nNewType)

enables or disables the property from nIndexPage page at nIndexProperty position


BSTR

GetPropertyAs(short nIndexPage, short nIndexProperty)

returns one of the following
values: "Edit", "CombBox", "BoolComboBox" etc


boolean

IsProperty(short nIndexPage, short nIndexProperty)

returns True is property nIndexProperty exists in nIndexPage page


long

GetIDListCtrl(short nIndexPage)

Return the identifier associated with the contained list control of page index nIndexPage.


short

GetActivePage()

returns the index of active page. If no page is active then it returns –1


IUnknown*

GetxFloorWnd()

Return pointer to interface to contained xFloorWnd Control


boolean

GetDefaultValue(short nIndexPage, short nIndexProperty, BSTR* sPropertyValue)

gets the value of nIndexProperty from nIndexPage page into the sPropertyValue. It returns true if the asked property exists


boolean

SetDefaultValue(short nIndexPage, short nIndexProperty, BSTR lpszDefaultvalue)

sets the value of property nIndexProperty from nIndexPage page to the lpszDefaultvalue


short

GetPropertyCount(short nIndexPage)

returns the number of properties from page nIndexPage


void

SetPropertyName(short nIndexPage, short nIndexProperty, BSTR lpszProperyName)

renames the property with the index nIndexProperty from nIndexPage page


boolean

GetPropertyIndex(BSTR lpszPropertyName, short* nIndexPage, short* nIndexProperty)

returns true if exists property lpszPropertyName. In nIndexPage will be the index of page and in nIndexProperty will be the position of property lpszPropertyName


boolean

SetDefaultValueByName(BSTR lpszPropertyName, BSTR lpszPropertyValue)

it does the same thing as the SetDefaultValue method just that the property is accessed by name


BSTR

GetDefaultValueByName(BSTR lpszPropertyName)

returns the value of property lpszPropertyName, for example, "Page1Item". If lpszPropertyName is not a valid property then the result is Null


short

GetActiveProperty(short* nIndexPage)

returns the position of active property from active page. nIndexPage will contain the value of GetActivePage. If no property is active then it returns –1.


boolean

SetActiveProperty(short nIndexPage, short IndexProperty)

activates the nIndexPage page and the nIndexProperty property. Returns true if everything was OK.


boolean

SetActivePropertyByName(BSTR lpszPropertyName)

it does the same thing as the SetActiveProperty method just that the property is accessed by name


boolean

DeletePropertyByName(BSTR lpszPropertyName)

deletes the property called lpszPropertyName. This lpszPropertyName can be in the path form such as : "Page1Item"


short

AddProperty(BSTR lpszPropertyName, BSTR lpszPropertyAs, short nPropertyType)

adds a new property called lpszPropertyName. LpszPropertyName can be something like this: "Page1Item" which means that property "Item" will be added in the page "Page1" , if this page will be found.


lpszPropertyAs parameter can have one of the following values :


  • "
Edit" property

  • "
  • Button" property

  • "
  • Link" for a link button. Same as button, Only picture is
    changed

  • "
  • Return" for a return button. Same as button, Only picture
    is changed

  • "
  • Font" property.

  • "
  • BoolComboBox" for a combo with two valuse
    "True" and "False"

  • "
  • ADORComboBox" for a multicolumn combobox who can
    store ADOR recordset.

  • "
  • DataComboBox" for a data property.

  • "
  • ComboBox" for a unboud combobox

  • "
  • ShellFolder" for a property who can set a path.

  • "
  • ColorComboBox" for a color property.

  • "
  • Group" property

  • "
  • NComboBox" property, based on Ncombo ActiveX
    Control

    void

    Init()

    Refresh the sizes of all windows attached to pages.


    long

    ColumnKey(short nIndexPage, short nIndexProperty)

    Return the column key for a

    ADORComboBox
    property.

    void

    ColumnKey(short nIndexPage, short nIndexProperty, long nNewValue)

    This method will specify which column from the dropdown you want to have as the value of property. This column has to be specified by index. Only in

    ADORComboBox

    long

    ColumnWidth(short nIndexPage, short nIndexProperty, long nColumn)

    Gives the width of a column. Only in

    ADORComboBox

    void

    ColumnWidth(short nIndexPage, short nIndexProperty, long nColumn, long nNewValue)

    Set the width of one column. This is useful when you want to hide some columns. To hide a column you’ll set the ColumnWidth to 0 Only in

    ADORComboBox

    BSTR

    ColumnName(short nIndexPage, short nIndexProperty, short nColumn)

    Gets the name of a column. Only in

    ADORComboBox

    void

    ColumnName(short nIndexPage, short nIndexProperty, short nColumn, BSTR lpszNewValue)

    Sets the name of a column. Only in

    ADORComboBox

    boolean

    ColumnHeader(short nIndexPage, short nIndexProperty)

    Return TRUE if the column header of

    ADORComboBox property is visible or not.

    Void

    ColumnHeader(short nIndexPage, short nIndexProperty, boolean bNewValue)

    Shows/Hides the column header of

    ADORComboBox
    property

    double

    DropDownWidth(short nIndexPage, short nIndexProperty)

    Gets the width of the dropdown. Only in

    ADORComboBox
    property

    void

    DropDownWidth(short nIndexPage, short nIndexProperty, double newValue)

    Sets the width of the dropdown. Only in

    ADORComboBox
    property

    long

    DropDownHeight(short nIndexPage, short nIndexProperty)

    Return the number of rows that you want to see in dropdown corresponding to the property that has the nIndexProperty index. Only for

    ADORComboBox property

    void

    DropDownHeight(short nIndexPage, short nIndexProperty, long nNewValue)

    sets the number of rows that you want to see in dropdown corresponding to the property that has the nIndexProperty index


    void

    RefreshProperty(short nIndexPage, short nIndexProperty)

    this is useful when you want to change the database source for an ADOR.Recordset associated with an

    ADORComboBox.

    VARIANT

    GetValue(short nIndexPage, short nIndexProperty, long nColumn)

    The same thing as GetDefaultValue, with some changes:


    ADORComboBox

    – return the value (as variant)
    of field from column nColumn (the selected item from
    combo)

    ColorComboBox

    – return the color as COLORREF
    from a ColorComboBox property.

    Font

    – return IfontDisp* from a Font property,
    for nColumn == 0

    Font

    – return COLORREF from a Font property
    (the color of font), for nColumn == 1

    NComboBox

    – return the value from nColumn column, if nColumn exist, or item data if not (<0 as sample)

    VARIANT

    GetValueByName(BSTR lpszPropertyName, long nColumn)

    The same as GetValue, only that the accessing to property is gave by name.


    BSTR

    ColumnKeyByName(short nIndexPage, short nIndexProperty)

    Return the name of column key for a

    ADORComboBox property

    void

    ColumnKeyByName(short nIndexPage, short nIndexProperty, BSTR lpszNewValue)

    Set the new column key for a

    ADORComboBox property, by name

    void

    SetValue(short nIndexPage, short nIndexProperty, VARIANT vValue, short nColumn)

    ColorComboBox

    – Set the new color of a
    ColorComboBox property

    Font

    – Set a new font (IfontDisp*) for Font
    property, if nColumn == 0

    Font

    – Set a new color font (COLORREF) for Font property, if nColumn == 1

    IDispatch*

    GetNComboObject(long nIndexPage, long nIndexProperty)

    Version 1.07


    Return the NCombo ActiveX Control dispinterface associatted with property nIndexPage, nIndexProperty

    Events

    :


































    Name


    Specification


    void

    SelectItem(short nIndexPage, short nIndexItem)

    Occurs when property (nIndexPage, nIndexItem) was selected.


    void

    SelectPage(short nIndex)

    Occurs when page nIndex was activated


    void

    UnselectItem(short nIndexPage, short nIndexItem)

    Occurs when property (nIndexPage, nIndexItem) was unselected


    void

    PropertyChanging(short nIndexPage, short nIndexProperty)

    Occurs before property (nIndexPage, nIndexItem) to be changed


    void

    PropertyChanged(short nIndexPage, short nIndexProperty, boolean bUpdate)

    Occurs after property (nIndexPage, nIndexItem) was changed. BUpdate is TRUE if value was changed or not


    void

    ButtonClick(short nIndexPage, short nIndexProperty)

    Occurs when user click into Button property. Only for:

    Button, Link, Return properties

    void

    LoadItems(short nIndexPage, short nIndexProperty, BSTR* lpszItems)

    before editing a combobox,
    this needs to be filled with items. For example if you want to have
    in the combobox the following items "Item1, Item2, Item3"
    in the property with the page index nIndexPage and property index
    nIndexProperty, the lpszItems has to be like this : lpszItems =

    "Item1Item2Item3". Only for

    ComboBox

    void

    SetObject(long nIndexPage, long nIndexProperty, IDispatch** pObject)

    the pObject parameter is the object that will contain the ADOR.Recordset object corresponding to the property that has nIndexProperty index.. This event is raised before the loading of the items of the control. It is also raised when you change the name of a column. Only for

    ADORComboBox.

    void

    Delete(short nIndexPage, short nIndexProperty)

    Occurs when user press VK_DELETE into property (nIndexPage, nIndexItem).


    Notices:


    • all BSTR returned by any functions (methods), in
      VC, need to be releases with ::SysFreeString

    • one property can be represents either: name or
      position (nIndexPage, nIndexItem)

    Download source – 239 KB

    CodeGuru Logo

    CodeGuru covers topics related to Microsoft-related software development, mobile development, database management, and web application programming. In addition to tutorials and how-tos that teach programmers how to code in Microsoft-related languages and frameworks like C# and .Net, we also publish articles on software development tools, the latest in developer news, and advice for project managers. Cloud services such as Microsoft Azure and database options including SQL Server and MSSQL are also frequently covered.

    Property of TechnologyAdvice. © 2026 TechnologyAdvice. All Rights Reserved

    Advertiser Disclosure: Some of the products that appear on this site are from companies from which TechnologyAdvice receives compensation. This compensation may impact how and where products appear on this site including, for example, the order in which they appear. TechnologyAdvice does not include all companies or all types of products available in the marketplace.