Accessing Data in DataGrid

B

Bruce LeMond

I'm wanting to check a column in a datagrid and take some
action if it equals a certain value. I have the following
Code:

Private Sub DataGrid1_CurrentCellChanged(ByVal sender As
Object, ByVal e As System.EventArgs) Handles
DataGrid1.CurrentCellChanged
rows = DataGrid1.CurrentCell.RowNumber
cols = DataGrid1.CurrentCell.ColumnNumber
End Sub

And then I have the following if statement somewhere else
in the program:

If DataSet1.Tables("ItemsOrder").Rows(rows)("Class") = "S"
Then
DisplaySpecialClass()
End If

When I tried running it, I'm still not getting the data
from the datagrid row that I selected. What would I be
doing wrong?

Thanks in advance.
 
K

Ken Tucker

Hi,

Dim dgCell As DataGridCell

dgCell = DataGrid1.CurrentCell

MessageBox.Show(DataGrid1.Item(dgCell).ToString)


Ken
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top