[DevExpress] GridControl selects a row based on the column, and gridcontrol hides the column.
[DevExpress] GridControl selects a row based on the column
Key code:
/// <Summary> /// select a row based on the column /// </summary> /// <param name = "gridView"> GridView </param> /// <param name = "colName"> column name </param> // <param name = "colValue"> column value </param> public static void SelectRow (this GridView gridView, string colName, object colValue) {gridView. clearSelection (); for (int rowHandle = 0; rowHandle <gridView. rowCount; rowHandle ++) {object _ cellValue = gridView. getRowCellValue (rowHandle , ColName); if (_ cellValue! = Null) {if (_ cellValue = colValue) {gridView. SelectRow (rowHandle); break ;}}}}
Sample Code:
gcLampConfig.UIThread<GridControl>(gc => gvLampConfig.SelectRow(gcKeyFieldName, _finded.LampID));
In DEVEXPRESS, can the Add check box of gridcontrol only select one of your columns that are bound to the data source? If no data source is bound, this column is dead unless you use the Unbound field to process it yourself. If you want to start all the tasks in the unselected status, you can bind a column with "false.
Now, with gridcontrol in devexpress, how can we split the cell String Based on the mouse position when you click a cell? It is difficult to have 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.
}
}
}