0
我已經開發了一個XtraGrid控件。但是,當winform加載時,我無法獲得默認選定行的ID。我知道如何在用戶點擊網格時獲得它。如何獲得Devexpress XtraGrid控件選定行
下面是代碼快照:
private void Form1_Load(object sender, EventArgs e)
{
grid1.DataSource = bindData(DataClassesDataContext.Table1.ToList());
ID = Convert.ToInt32(gridView.GetRowCellValue(gridView.FocusedRowHandle, "ID"));
XtraMessageBox.Show(ID.ToString());
}
public BindingSource bindData(object obj)
{
BindingSource ctBinding;
try
{
ctBinding = new BindingSource();
ctBinding.DataSource = obj;
return ctBinding;
}
catch (Exception ex)
{
XtraMessageBox.Show(ex.Message, "Database Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
return null;
}
}
'Table1'中的類型是什麼? –
它是一個使用LINQ to SQL訪問的表對象 – aby
您可以指定您遇到的問題。我不認爲我明白你的需要。 –