简体   繁体   English

如何在devexpress gridcontrol中使用buttonedit

[英]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.

相关问题 如何使用 DevExpress DashboardDesigner.SelectedDataSource 填充 GridControl/DataGridView - How to use DevExpress DashboardDesigner.SelectedDataSource to fill the GridControl/DataGridView 如何在 devexpress 中向 GridControl 添加控件? - How to add controls to a GridControl in devexpress? 如何用动态对象填充DevExpress GridControl - How to populate DevExpress GridControl with Dynamic Objects 如何在DevExpress GridControl中填充最后一列的宽度? - How to fill width of last column at DevExpress GridControl? 如何在DevExpress GridControl中显示RepositoryItemHyperLinkEdit控件 - How to display a RepositoryItemHyperLinkEdit control inside a DevExpress GridControl 如何在未绑定的devexpress GridControl中添加新行? - How to add new row to unbound devexpress GridControl? 如何隐藏devexpress GridControl的特定行? - How to hide a specific row of devexpress GridControl? 如何在gridcontrol devexpress中添加popupcontainer编辑 - How to add popupcontainer edit in the gridcontrol devexpress 如何用字符串和日期字段填充DevExpress GridControl? - How to fill a DevExpress GridControl with string and date fields? 如何将数组列表作为数据源添加到devexpress gridcontrol - How to add an arraylist as datasource to devexpress gridcontrol
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM