[DevExpress] GridControl obtains the cell value based on RowIndex and VisibleColumnsIndex, devexpressgrid

Source: Internet
Author: User

[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)
{

}
}

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.