How to read the value of a DataGrid cell

Hi,

What I need to do is very simple, but I cannot find the syntax.

I only need the value of a named column in the current row. As in:

dim var as string = datagrid1.columns("JobNumber").value

In VB6 that was the syntax, but 2005 does everything but the ".value"

in intellesense.

How do I get the value in the column called "JobNumber"




Answer this question

How to read the value of a DataGrid cell

  • Rohit Tela

    if you are using a datagridview you could also do this:

    Dim theValue as object = Me.theDataGridView.Rows(RowIndex).Cells(ColumnName).Value



  • JavaBoy

    Thank you both for the response.

    I finally ended up with this code (actual from the program)

    defaultJobNumber = Me.dgView1.Rows(dgView1.CurrentRow().Index).Cells("Job").Value

    defaultCallNumber = Me.dgView1.Rows(dgView1.CurrentRow().Index).Cells("CallNumber").Value

    The function the code resides in is a button click event so I did not have the advantage of a passed parameter like "currentRow" or "currentColumn", but this works. Also I found I an using a datagridview (I didn't know there was more than one type of datagrid). Thanks for drawing my attention to this.

    So Thanks for the help.

    Rich



  • a23rd

    Dim CellValue As Object = datagrid1.Item(datagrid1.CurrentRowIndex, ColumnNumber)



  • How to read the value of a DataGrid cell