private void InitControl()
{
this.gdvDetail.OptionsBehavior.Editable = true;//表单内容可修改
this.gdvDetail.OptionsSelection.EnableAppearanceFocusedCell = true;//光标选择单元格
}
======================
EventList
#region Control Event
//模拟行双击事件
private void gdvDetail_DoubleClick(object sender, EventArgs e)
{
MouseEventArgs arg = e as MouseEventArgs;
if (arg == null || arg.Button != MouseButtons.Left)
{
return;
}
DevExpress.XtraGrid.Views.Grid.ViewInfo.GridHitInfo hitInfo = gdvDetail.CalcHitInfo(new Point(arg.X, arg.Y));//获取坐标点
if (hitInfo.RowHandle >= 0)
{
//取得选定行信息
string nodeID = gdvDetail.GetRowCellValue(hitInfo.RowHandle, "EVENT_ID").ToString();
string sModelVer = cboModelVer.EditValue.ToString();
string sIndexes = "LOOKUP";
//frmFDCEventSetup frm = new frmFDCEventSetup("frm", new string[] { sIndexes, GlobalVariable.gsFactory, nodeID, sModelVer });
//string nodeName = gdvDetail.GetRowCellValue(hitInfo.RowHandle, "PRV_GRP_DESC").ToString();
CommonFunction.OpenForm(CommonFunction.GetMenuTag(GlobalConstant.FORMID_FDC_EVENT_SETUP),
"Event - "+ nodeID, new string[] { sIndexes, GlobalVariable.gsFactory, nodeID, sModelVer });
//CommonFunction.OpenForm(mTag, "Privilege Group - " + nodeName, new string[] { GlobalVariable.gsFactory, nodeID });
}
}
#endregion
#region Item Add Data
//向"MODULE_VER"下拉列表中添加数据
private void cboModelVerAddData()
{
DataTable dt = ListRoutineFDC.ViewFDCResModelVersionList(sProcStep: '2');
DataRow dr = dt.NewRow();
dr[0] = "";
dt.Rows.InsertAt(dr, 0);
DevGridLookupHelper.InitPopup(this.cboModelVer, new string[] { "选择模块ID" }, dt);
}
#endregion
#region select many
private int GetRowAt(GridView view, int x, int y)
{
return view.CalcHitInfo(new Point(x, y)).RowHandle;
}
//鼠标按下触发gdvPO_MouseDown事件
private void gdvDetail_MouseDown(object sender, MouseEventArgs e)
{
StartRowHandle = GetRowAt(sender as GridView, e.X, e.Y);
}
//鼠标松开触发gdvPO_MouseDown事件
private void gdvDetail_MouseUp(object sender, MouseEventArgs e)
{
StartRowHandle = -1;
CurrentRowHandle = -1;
timer1.Stop();
}
private void SelectRows(GridView view, int startRow, int endRow)
{
if (startRow > -1 && endRow > -1)
{
view.BeginSelection();
view.ClearSelection();
view.SelectRange(startRow, endRow);
view.EndSelection();
}
}
private void gdvDetail_MouseMove(object sender, MouseEventArgs e)
{
if (e.Button == MouseButtons.Left)
{
GridView view = sender as GridView;
GridViewInfo info = view.GetViewInfo() as GridViewInfo;
GridHitInfo hi = view.CalcHitInfo(e.Location);
int newRowHandle = GetRowAt(sender as GridView, e.X, e.Y);
if (CurrentRowHandle != newRowHandle)
{
CurrentRowHandle = newRowHandle;
SelectRows(sender as GridView, StartRowHandle, CurrentRowHandle);
}
if (info.RowsInfo.Count < 1)
{
return;
}
if (info.RowsInfo.Count >= 2 && info.RowsInfo[info.RowsInfo.Count - 2].RowHandle == hi.RowHandle)
{
scrollDown = true;
if (!timer1.Enabled)
timer1.Start();
}
else
{
if (info.RowsInfo[0].RowHandle == hi.RowHandle)
{
scrollDown = false;
if (!timer1.Enabled)
timer1.Start();
}
else
timer1.Stop();
}
}
}
private void timer1_Tick(object sender, EventArgs e)
{
if (scrollDown)
{
gdvDetail.TopRowIndex++;
}
else
{
gdvDetail.TopRowIndex--;
}
Point ee = gdcDetail.PointToClient(MousePosition);
int newRowHandle = GetRowAt(gdvDetail, ee.X, ee.Y);
if (CurrentRowHandle != newRowHandle)
{
CurrentRowHandle = newRowHandle;
SelectRows(gdvDetail, StartRowHandle, CurrentRowHandle);
}
}
#endregion