An Enhanced Combo Box Control.

The ActiveX control demonstarted in this article - NCombo Control (see figure) looks like a combobox control, and has more features such as:

  • allows more than one column into control (multicolumn);
  • each column has an edit control associated. The goal of edit is the same as the standard combobox: searching, selecting. Each edit associated has more properties: enable/disable, show/hide, width. At one moment a single column can be activated.
  • allows navigating through columns by pressing TAB for next column, SHIFT+TAB for previous column.
  • each column can be resized at runtime, by dragging the column limits.
  • allows search for next matching item by pressing F3, backward searching, with SHIFT+F3, or continue search by adding more constraints.

Image of the control

The control offers the following properties, methods and events:

Properties

Type

Name

Parameters

Specification

bool

ColumnEnable

long nColumn

Get: Return TRUE if the column with index nColumn is enabled.

Set: Enable/Disable the column with index nColumn.

bool

ColumnVisible

long nColumn

Get: Return TRUE if the column with index nColumn is visibled.

Set: Show/Hide the column with index nColumn.

long

ColumnWidth

long nColumn

Get: Return the width of the column with the index nColumn.

Set: Set the width of the column with the index nColumn.

Methods:

Type

Name

Parameters

Specification

long

InsertColumn

long nColumn

CString sColumnName

long nWidth

long nJustify

bool bEnable

bool bVisible

Insert a column at nColumn position. If this position is greater than the number of columns then it will be added at the end.

  • sColumnName parameter represents the name associated to that column.
  • nWidth parameter specifies the width of the column
  • nJustify specifies the position of the text in the cell (0 – left, 1 – right, 2 –center)
  • bEnable specifies if the column is enabled or not
  • bVisible specifies if the column is visible or not

bool

DeleteColumn

long nColumn

Delete the column with the index nColumn.

Return TRUE if the column was deleted.

long

GetColumnCount

 

Return the number of columns

CString

GetColumnName

long nColumn

Return the name of the column with the index nColumn

long

InsertItem

long nItem

CString sItem

Insert an item at nItem position.

- sItem is the default value for the first column.

bool

DeleteItem

long nItem

Delete the item with the nItem index

Return TRUE if the operation has terminated successfully

bool

SetItemData

long nItem

long wData

This method associates a certain data to the item with the index nItem. This is useful, for example, when you have in the combobox a recordset and for each item with the index nItem you want the AbsolutePosition in the recordset.

Return TRUE if the operation has terminated successfully

bool

SetItemText

long nItem

long nColumn

CString sText

Put in the column nColumn of the item nItem the text sText

Return TRUE if the operation has terminated successfully

long

GetItemCount

 

Returns the number of items

long

GetItemData

long nItem

Returns the data associated to the item nItem.

CString

GetItemText

long nItem

long nColumn

Returns the text from the column nColumn of the item nItem.

Events:

Name

Parameters

Specification

ChangingItem

long nItem

This event is raised when you move through items but you don’t select anyone (the header is not changed).

ChangedItem

long nItem

This event is raised when you select an item (so when the header is changed).

ChangeColumnKey

long nColumn

This item is raised when the column key of the column nColumn is changed.

ChangeColumnContent

long nColumn

CString sColumnContent

long nType

This event is raised when you change the content of a column.

- sColumnContent represents the current content of the column with the index nColumn.

Download demo project - 187 KB

Download source - 7 KB



Comments

  • KUDOS FROM P SANTHOSH PILLAI HOBBY VC++ PROGRR

    Posted by psanthosh on 06/01/2009 09:12am

    LOOKS LIKE A VERY GOOD STUFF ... THERE ARE THINGS THAT REALLY MATTER

    Reply
Leave a Comment
  • Your email address will not be published. All fields are required.

Top White Papers and Webcasts

  • Live Event Date: March 19, 2015 @ 1:00 p.m. ET / 10:00 a.m. PT The 2015 Enterprise Mobile Application Survey asked 250 mobility professionals what their biggest mobile challenges are, how many employees they are equipping with mobile apps, and their methods for driving value with mobility. Join Dan Woods, Editor and CTO of CITO Research, and Alan Murray, SVP of Products at Apperian, as they break down the results of this survey and discuss how enterprises are using mobile application management and private …

  • According to technology research firm Gartner, cloud computing will become the bulk of new IT spend by 20161. By the end of 2017, Gartner predicts that nearly half of large enterprises will have hybrid cloud deployments1. Learn how you can use these trends to your advantage by offering cloud and hybrid data solutions to your customers.

Most Popular Programming Stories

More for Developers

RSS Feeds

Thanks for your registration, follow us on our social networks to keep up-to-date