[英]how to use buttonedit in devexpress gridcontrol
I am trying to create a gridcontrol with buttonedit in one of the columns. 我正在尝试在其中一列中创建带有buttonedit的gridcontrol。 When the user clicks the button edit, it popups up a form to select a product. 当用户单击编辑按钮时,它将弹出一个表单以选择产品。 When the selection is done on the popup, It returns the DataRow from the selection to the main grid like below. 在弹出窗口上完成选择后,它将DataRow从选择返回到主网格,如下所示。
but when the column loses the focus, the value I wrote to the column disappear. 但是当该列失去焦点时,我写入该列的值就会消失。
here is my code which creates the gridcontrol's data and buttonedit's click event. 这是我的代码,它创建gridcontrol的数据和buttonedit的click事件。
private void FrmSiparisNew_Load(object sender, EventArgs e)
{
dt = new DataTable();
dt.Columns.Add("MALZEME_KODU",typeof(string));
dt.Columns.Add("MALZEME_ACIKLAMA", typeof(string));
dt.Columns.Add("ADET", typeof(decimal));
dt.Columns.Add("BIRIM", typeof(string));
dt.Columns.Add("FIYAT", typeof(decimal));
dt.Columns.Add("KUR", typeof(string));
dt.Columns.Add("TUTAR", typeof(decimal));
DataRow dr = dt.NewRow();
dt.Rows.Add(dr);
gc.DataSource = dt;
}
private void repositoryItemButtonEditMalzemeKodu_ButtonClick(object sender, DevExpress.XtraEditors.Controls.ButtonPressedEventArgs e)
{
FrmProducts frm = new FrmProducts(dt_products);
frm.ShowDialog();
DataRow dr_return = frm.dr;
ButtonEdit buttonEdit = (sender as ButtonEdit);
buttonEdit.Text = dr_return["URUNKOD"].ToString();
}
why does the value disappear? 为什么价值消失了? should I first fill the datatable and bind it again? 我应该首先填充数据表并再次绑定它吗? how can I fix this? 我怎样才能解决这个问题?
It looks like the button edit is not connected intimately with the hosting grid. 看来按钮编辑未与托管网格紧密相连。 See if you can assign the value to the underlying grid cell or datatable row value. 查看是否可以将值分配给基础网格单元格或数据表行值。 Then, it should stick. 然后,它应该粘住。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.