[DevExpress]GridControl根据列来选中一行

关键代码:

        /// <summary>

        /// 根据列来选中一行

        /// </summary>

        /// <param name="gridView">GridView</param>

        /// <param name="colName">列名称</param>

        /// <param name="colValue">列值</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;

                    }

                }

            }

        }

代码示例:

gcLampConfig.UIThread<GridControl>(gc => gvLampConfig.SelectRow(gcKeyFieldName, _finded.LampID));

你可能感兴趣的:(DevExpress)