views:

148

answers:

2

I am working on a smartphone application, where I have a DataGrid in winform.

I want to get the value of cell of the selected row..

+2  A: 

Through lack of information here is a hack of one if our methods from an old VB.net compact framework project.

For i As Integer = 1 To DataGrid.VisibleRowCount - 1

  If DataGrid.IsSelected(i) Then

    MessageBox.Show(DataGrid.Item(i, 0).ToString())

  End If

Next

This will show a message box with the contents of the first cell of each selected row.

Zordey
thanks for answer but there no function like DataGrid.Item(i, 0) in DataGrid ... please verify it
Azhar
Hi, as I said this is an old project for a Win CE5 PDA device using compact framework 2.0.I dont actually have a later version currently installed to test.you could try something like: DataGrid.row(i)(0).tostring()Sorry for not being more help.
Zordey
Sorry but there is no row function in DataGrid in smartphone application. I got it. thanks for reply...
Azhar
@Azhar: Your answer is the same as `dgDataGrid.Item(i, 0)` as shown in @Zordey's answer. This is because VB.NET allows the user to call the `Item` method directy. This method is an "indexer" property. In C# this method is "hidden" and accessed as `this[index]`. In VB.NET, you can access as `Me(index)` or `Me.Item(index)`.
AMissico
A: 

This will return the value of selected cell of DataGrid in smartphone application

   MessageBox.Show(dgDataGrid[dgDataGrid.CurrentCell.RowNumber,
 dgDataGrid.CurrentCell.ColumnNumber].ToString());

Through this you can get or set the cell value.

Azhar
@Azhar: Your answer is the same as `dgDataGrid.Item(i, 0)` as shown in @Zordey's answer. This is because VB.NET allows the user to call the `Item` method directy. This method is an "indexer" property. In C# this method is "hidden" and accessed as `this[index]`. In VB.NET, you can access as `Me(index)` or `Me.Item(index)`.
AMissico