Home All Groups Group Topic Archive Search About
Author
23 Apr 2005 4:02 PM
Simon Abolnar
I would like to read data from datagrid.
How can I read one cell from datagrid (raw, column).

How can I find out total numbers of raws.

Thanks for help,

Simon

Author
23 Apr 2005 7:50 PM
Scott Mitchell [MVP]
Simon Abolnar wrote:
> I would like to read data from datagrid.
> How can I read one cell from datagrid (raw, column).
>
> How can I find out total numbers of raws.

By "raw" I assume you mean "row"...

You can determine the total number of rows using the following property:

    DataGridID.Items.Count

You can access a particular cell of the DataGrid using the following code:

    'VB.NET
    Dim cell as TableCell = DataGridID.Items(rowIndex).Cells(colIndex)

    // C#
    TableCell cell = DataGridID.Items[rowIndex].Cells[colIndex];

Once you have the TableCell instance you can read the text contents via
the .Text property.  (If it's a TemplateColumn you will need to work
through the control hierarchy... see the following two FAQs for how to
programmatically work with the contents of BoundColumns and TemplateColumns:

http://datawebcontrols.com/faqs/ProgrammaticAccess/AccessingBoundColumnContents.shtml
http://datawebcontrols.com/faqs/ProgrammaticAccess/AccessingTemplateColumnContents.shtml

hth