4

I am building a mobile application which allows operators to manage their jobs in the field. I am using a datagrid to display the users Job list. The user will be able to accept or decline jobs by selecting the gridview row and assigning a status to it via a combo box.

To do this I need to get the value of cell 9 (JobID) for the selected row of the datagrid. Because I am using .NET Compact framework I'm unable to access certain properties such as SelectedRow. I've spent all morning trawling the web for pointers but most examples I find are targeted at .NET framework, rather than .NET Compact Framework. This is no help to me at all because all examples seem to reference System.Web.UI which I am led to believe isn't available for .NET CF

Can anyone offer me any suggestions to achieve this for smart device applications. All help will be greatly appreciated.

Thanks in advance.

Gary Green
  • 87
  • 2
  • 9

2 Answers2

6

I would use the CurrentCell propery on the datagrid to determin what row that has focus and then select out the wanted value from that row.

int row = dgJobList.CurrentCell.RowNumber;
int column = 9;
string cellValue = dgJobList[row,column].toString();
Mattias Josefsson
  • 1,147
  • 1
  • 7
  • 22
  • ok, you'll have to excuse me because I am a bit of a noob when it comes to C#.NET i've come from a PHP background so not familiar with all mothods / properties yet. Im guessing I would use **dgJobList.CurrentCell.RowNumber** to get the selected row but how do I set **dgJobList.CurrentCell.ColumnNumber** to 9 and the return that cells value. Thank you for the help – Gary Green Dec 21 '12 at 10:59
  • The code above gets the value from the selected rows column with index 9 and depending on what it is it might need to be casted to the right type. – Mattias Josefsson Dec 21 '12 at 11:08
  • Thank you very much that was a massive help, really appreciated! – Gary Green Dec 21 '12 at 11:15
0

thank you @mattias. As a VB .net user I will give my own code to do the same thing.

dim rom as integer

dim column as integer

dim cellvalue as string

row = dgJobList.CurrentCell.RowNumber

column = 9

cellValue = dgJobList(row,column).toString()

You can use ctype() to get the content of the cell with a specific type.

Robert
  • 5,278
  • 43
  • 65
  • 115