Devexpress gridView.Rows?

I want to do this with the Devexpress (gridview) extension:

string dataInCell = dataGridView1.Rows[i].Cells[j].Value.ToString(); 

Like:

 gridView1.Rows[i].Cells[j] 
+4
source share
10 answers

If you are trying to get the cell value in the specefic line, here is how:

a. If you want the cell value of the focused row:

 view.GetFocusedRowCellValue("fieldName"); 

b. If you want the cell value of a row to know its handle:

 view.GetRowCellValue(rowHandle, "fieldName"); 

Good luck.

+7
source

try it

  for (int i = 0; i < gridView.RowCount; i++) { dataInCell = Convert.ToString(gridView.GetRowCellValue(i, "FieldName")); } 
+5
source

To get a spescific string, you can use these commands.

 GridView.GetDataRow(rowHandle) 

or

 GridView.GetRow(rowHandle) 

but if you want to change the range of cells, it is usually better to go directly to the data source

+1
source

Did you presumably set the datasource on the grid? If so, use the data source and access it through its datasource index.

Using line descriptors can cause problems when sorting the grid. I recommend...

 int dataIndex = gridView.GetDataSourceRowIndex(rowHandle); var myData = myDataSource[dataIndex]; 

Provided that you use a universal collection, the cast is not involved in it, and this handles grouping and sorting. Of course, what is displayed and what data may not match. For example, if the data is an enumeration. To do this, you would display the display name, but the value in the data source is enum. Usually I need a base value instead of the displayed text.

+1
source

you can use the code below:

 dataGridView1.GetRowValues(dataGridView1.FocusedRowIndex,"column1-name","column2-name",...); 

with this, you can get the value with the row index, which is focused on it, and choose with the field name returned by the value of the object type and you pass int, string and ... such as:

 string id=(string)dataGridView1.GetRowValues(dataGridView1.FocusedRowIndex,"column1-name"); 

but it depends on the type column1-name

0
source
 string dataInCell = ((DataRowView)gridControl1.MainView.GetRow(i)).Row.ItemArray[j].ToString(); 
0
source

I think you are looking for this:

 string str = gridView1.GetRowCellValue(Convert.ToInt32("ROW_NUMBER"), "COLUMN_NAME").ToString(); 
0
source

you should use GetRowCellValue

 string cellValue; cellValue = gridView1.GetRowCellValue(2, "ID").ToString(); 
0
source

You can do all of the above steps, but keep in mind that an error message will be displayed in the dialog with zero values, so before accessing it, execute Convert.IsDBNull ().

0
source

I think this is the best code to get the column column field of a row.

int row = gridView1.GetRowCellValue (gridView1.FocusedRowHandle, "Identity"). ToString (),

0
source

All Articles