Exemple #1
0
 private void SelectRow()
 {
     gridView.ClearSelection();
     if (selectedIndex > -1)
     {
         int dataIndex = gridView.GetRowHandle(selectedIndex);
         gridView.SelectRow(dataIndex);
         gridView.FocusedRowHandle = dataIndex;
     }
     else if (IsAutoSelectFirst)
     {
         gridView.SelectRow(0);
         gridView.FocusedRowHandle = 0;
     }
 }
Exemple #2
0
        static public int gridviewFindValueRowHandle(DevExpress.XtraGrid.Views.Grid.GridView _grid_view, String _field_name, object _value, bool _isSelect = false)
        {
            int retRowHandle = -1;

            if (_field_name == String.Empty || _value == null || _grid_view == null)
            {
                return(retRowHandle);
            }

            //System.Data.DataTable dt = (System.Data.DataTable)_grid_view.GridControl.DataSource;

            //System.Data.DataRow[] dtRows;
            //dtRows = dt.Select(String.Format("{0} = {1}", _field_name, _value.ToString()));

            //if (dtRows.Count() > 0)
            //{
            //    //dtRows[0];
            //}

            for (int i = 0; i < _grid_view.RowCount; i++)
            {
                object temp_obj;
                temp_obj = _grid_view.GetRowCellValue(i, _field_name);

                if (temp_obj.Equals(_value))
                {
                    retRowHandle = i;
                    break;
                }
            }

            if (_isSelect)
            {
                _grid_view.SelectRow(retRowHandle);
                _grid_view.FocusedRowHandle = retRowHandle;
            }

            return(retRowHandle);
        }