日期:2014-05-16  浏览次数:21005 次

C# 根据列名与列值设置当前行
        /// <summary>
        /// 根据GridView中某列的值与列名来设置当前行
        /// </summary>
        /// <param name="gv">待设置当前行的GridView</param>
        /// <param name="FilterCellValue">某列的值</param>
        /// <param name="CellName">列名</param>
        public void SetFocusedRow(DevExpress.XtraGrid.Views.Grid.GridView gv, string FilterCellValue, string CellName)
        {
            for (int i = 0; i < gv.RowCount; i++)
            {
                if (FilterCellValue == gv.GetRowCellValue(i, CellName).ToString())
                {
                    gv.FocusedRowHandle = i;
                }
            }
        }