Dev中GridControl中クリックイベント
2014 ワード
テストデータバインドgridcontrol:
フォーカス行の取得:
ハンドルでSystemを取得する.Data.DataRowView bView = gridView1.GetRow(int rowHandle) as System.Data.DataRowView;
DataTable dt = new DataTable();//
dt.Columns.Add("ID", typeof(Int32));//
dt.Columns.Add("Name", typeof(String));
dt.Columns.Add("Age", typeof(Int32));
dt.Rows.Add(new object[] { 1, " ", 20 });//
dt.Rows.Add(new object[] { 1, " ", 20 });//
dt.Rows.Add(new object[] { 2, " ", 25 });
dt.Rows.Add(new object[] { 3, " ", 30 });
gridControl1.DataSource = dt;
フォーカス行の取得:
ハンドルでSystemを取得する.Data.DataRowView bView = gridView1.GetRow(int rowHandle) as System.Data.DataRowView;
int a = gridView1.FocusedRowHandle;
System.Data.DataRowView bView = gridView1.GetRow(a) as System.Data.DataRowView;
gridcontrolダブルクリックイベント:
private void gridControl1_DoubleClick(object sender, EventArgs e)
{
System.Data.DataRowView pView = gridView1.GetFocusedRow() as System.Data.DataRowView; //
if (pView != null)
{
object id = pView.Row["ID"];
}
}
gridView行クリックイベント:
private void gridView1_RowClick(object sender, DevExpress.XtraGrid.Views.Grid.RowClickEventArgs e)
{
System.Data.DataRowView pDataRowView = this.gridView1.GetRow(e.RowHandle) as System.Data.DataRowView;
string strFieldName = string.Empty;
foreach (DataColumn mColumn in pDataRowView.Row.Table.Columns) //
{
if (mColumn.ColumnName.ToUpper().Contains("FID"))
{
strFieldName = mColumn.ColumnName;
break;
}
else if (mColumn.ColumnName.ToUpper().Contains("ID"))
{
strFieldName = mColumn.ColumnName;
break;
}
}
if (strFieldName != string.Empty) //
{
object a=pDataRowView[strFieldName]; //
}
}