Articles in this section

How to extract the entire data for particular column in WinForms GridControl?

Extract the entire data

The values of a specific column can be obtained by using the DrawCellDisplayText event. This event occurs for every cell before the grid draws the display text for the specified cell. But you have a limitation here; this event gets triggered only when the cell is in the view state. In this sample, we have added the second column's value to a list box control using a button click.

 

The rows that do not come into view will not be added to the list. So, iteration would be the only way to get the values of other cells that are not viewable.

void grid_DrawCellDisplayText(object sender, GridDrawCellDisplayTextEventArgs e)
{
    if (e.ColIndex == 2 && e.RowIndex > 0 && !list1.Contains(e.DisplayText))
    {
        list1.Add(e.DisplayText);
    }
}
Private Sub grid_DrawCellDisplayText(ByVal sender As Object, ByVal e As GridDrawCellDisplayTextEventArgs)
 If e.ColIndex = 2 AndAlso e.RowIndex > 0 AndAlso (Not list1.Contains(e.DisplayText))        Then
  list1.Add(e.DisplayText)
 End If
End Sub

The screenshot below illustrates the extracted data for the particular column.

 

Extract entire data for particular column

 

Samples:

C#: ExtractData_C#

VB: ExtractData_VB

Did you find this information helpful?
Yes
No
Help us improve this page
Please provide feedback or comments
Comments (0)
Access denied
Access denied