gridview上navigatr添加按钮事件,手动添加的行,取消自动添加行
View Code
private void grcPPintervalDetail_EmbeddedNavigator_ButtonClick(object sender, DevExpress.XtraEditors.NavigatorButtonClickEventArgs e)
{
if (e.Button.ButtonType == DevExpress.XtraEditors.NavigatorButtonType.Append)
{
try
{
ApplyEdit();
if (!string.IsNullOrEmpty(glucInvCName.EditValue.ToString()))
{
e.Handled = true;//取消默认新增事件
grvPPintervalDetail.AddNewRow();
int lineNum = grvPPintervalDetail.RowCount;
grvPPintervalDetail.RefreshData();
grvPPintervalDetail.MoveLast();
string code = "";
if ((1 < lineNum || lineNum == 1) && (lineNum < 9 || lineNum == 9))
{
code = "00" + lineNum;
}
if (10 <= lineNum)
{
code = "0" + lineNum;
}
grvPPintervalDetail.SetFocusedRowCellValue(grvPPintervalDetail.Columns["PPIntervalCode"], (glucInvCName.EditValue.ToString() + code).ToString());
}
else
{
e.Handled = true;//取消默认新增事件
MessageBox.Show("请先选择商品大类!");
}
}
catch (Exception ex)
{
MessageBox.Show(ex.Message);
}
}
}