[DevExpress] GridControl obtains the cell value based on RowIndex and VisibleColumnsIndex, devexpressgrid
Key code:
/// <Summary> /// obtain the visible cell value based on rowIndex and visibleColumnsIndex /// </summary> /// <param name = "view"> GridView </param> /// <param name = "rowIndex"> rowIndex </param> /// <param name = "visibleColumnsIndex"> visibleColumnsIndex </param> /// <returns> Cell visible value </returns> public static string GetRowCellDisplayText (this GridView view, int rowIndex, int visibleColumnsIndex) {return view. getRowCellDisplayText (rowIndex, view. visibleColumns [visibleColumnsIndex]);} /// <summary> /// obtain the cell value based on rowIndex and visibleColumnsIndex /// </summary> /// <param name = "view"> GridView </param> /// <param name = "rowIndex"> rowIndex </param> /// <param name = "visibleColumnsIndex"> visibleColumnsIndex </param> /// <returns> cell value </returns> public static object GetRowCellValue (this GridView view, int rowIndex, int visibleColumnsIndex) {return view. getRowCellValue (rowIndex, view. visibleColumns [visibleColumnsIndex]);}
Hope this is helpful!
Now, it is difficult to use gridcontrol in devexpress to split the cell String Based on the mouse position when you click a cell.
There is a GridView in GridControl, such as: gridview
// Click the event triggered by a cell
Void GridView_MouseUp (object sender, MouseEventArgs e)
{
GridHitInfo HitInfo = gridview. CalcHitInfo (e. Location); // obtain the cursor position
If (HitInfo. InRowCell & HitInfo. Column! = Null)
{
GridCell [] gridCells = gridview. GetSelectedCells (); // obtain the selected Cell set
Foreach (GridCell cell in gridCells) // traverses the selected cell
{
String value = gridview. GetRowCellValue (cell. RowHandle, cell. Column). ToString (); // obtain the selected cell value
// Split the cell string: value
I don't know how to separate this code.
}
}
}
It's tricky. DevExpress now has a gridcontrol to get the cell content of the new row, not the cell found below.
How does one get the content of a cell? Is this line selected with the mouse? Or click the button to save the data of the new row?
GridView1.GetFocusedRowCellValue (); this can obtain the content of the selected row.
///// Click the Save button to obtain the new row. Method not tested.
For (int I = 0; I <dxgv_Process.DataRowCount; I ++)
{
System. Data. DataRow row = dxgv_Process.GetDataRow (I );
If (row. RowState = System. Data. DataRowState. Added)
{
}
}