GridControl獲取選中行的ID或者獲取選中行的實體類


通過列名獲取選中行的ID

private string GetSelectID(string FileName)
{
int[] pRows = this.gdv.GetSelectedRows();//傳遞實體類過去 獲取選中的行
if (pRows.GetLength(0) > 0)
return gdv.GetRowCellValue(pRows[0], FileName).ToString();
else
return null;
}

GetSelectID(string FileName)//調用的時候直接傳入想要獲取的單元格的列名

 

獲取實體類

List<EntityEmployee> entityEmployees = new List<EntityEmployee>();

var list = gridControl.DataSource as List<EntityEmployee>;獲取到當前GridControl中綁定的數據源List<EntityEmployee>;

if (list == null || list.Count == 0) { return; }判斷獲取到的list集合是否為空

entityEmployees = list.FindAll(t => t.IsUpdate);在按條件進行篩選得到實體類

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM