This message contains graphics. If you do not see the graphics: Graphic Version.
 
How To Select Multiple Table Cells, FREE Text Editor

How To Select Multiple Table Cells In 1 Or More Tables - Part 1

Here in the Support Department, we are frequently asked how to show the user which table cell has been selected or is currently active. We therefore decided it would be a good idea to make a sample application that shows how to select several table cells and change their attributes.

In the following example we will show you how to highlight table cells using the mouse. The cells do not have to be adjacent to each other nor do they even have to be in the same table.

If you build this into your application, the end-user can select several cells and set, for example, the table cell's border.

We use a class CTableData to store the values of the selected table cell. CellList is a collection that contains all selected table cells.

If a new table cell has been selected a new instance of CTableData is created. If this table cell has not already been selected, the BackColor will be changed and the cell will be added to the Collection CellList.

If TXTextControl1.TableAtInputPos <> 0 Then Dim data As New CTableData data.SetID TXTextControl1.TableAtInputPos data.SetRow TXTextControl1.TableRowAtInputPos data.SetCol TXTextControl1.TableColAtInputPos nIndex = IsSelected(data) If (nIndex <> 0) Then TXTextControl1.TableCellAttribute(data.GetID, data.GetRow, data.GetCol,txTableCellBackColor) = vbWhite CellList.Remove nIndex Else TXTextControl1.TableCellAttribute(data.GetID, data.GetRow, data.GetCol,txTableCellBackColor) = &HE0E0E0 CellList.Add data End If Set data = Nothing End If

The function IsSelected checks if the currently selected table cell has been selected before.

Private Function IsSelected(data As CTableData) As Long Dim nIndex As Long nIndex = 1 For Each Cell In CellList If (Cell.GetID = data.GetID And Cell.GetRow = data.GetRow And Cell.GetCol = data.GetCol) Then IsSelected = nIndex Exit Function End If nIndex = nIndex + 1 Next Cell IsSelected = 0 End Function

Now the TableCellAttibutes can be changed for every cell in the Collection.

Download the demo project to see how it works in detail.

FREE Text Editor - Source Edit

Source Edit is a FREE text editor especially made for developers. It has fast syntax highlighting for several common computer languages. Download your free copy today at:

http://www.sourceedit.com/


Best regards

The Newsletter Team

Text Control GmbH respects your online time and privacy. We only send this newsletter to TX Text Control customers and people who have signed up to receive it. However, if you would prefer not to receive future issues of the newsletter, you may unsubscribe at any time. If you received this newsletter forwarded from a colleague or friend, you may wish to subscribe directly.

Sent to: N/A.

Imprint | Unsubscribe | Subscribe

© 2002 Text Control GmbH. All Rights Reserved.