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

  • Packaged application development teams frequently operate with limited testing environments due to time and labor constraints. By virtualizing the entire application stack, packaged application development teams can deliver business results faster, at higher quality, and with lower risk.

  • Live Event Date: September 10, 2014 @ 11:00 a.m. ET / 8:00 a.m. PT Modern mobile applications connect systems-of-engagement (mobile apps) with systems-of-record (traditional IT) to deliver new and innovative business value. But the lifecycle for development of mobile apps is also new and different. Emerging trends in mobile development call for faster delivery of incremental features, coupled with feedback from the users of the app "in the wild". This loop of continuous delivery and continuous feedback is …

Most Popular Programming Stories

More for Developers

Latest Developer Headlines

RSS Feeds