本文介绍了如何在devexpress gridcontrol中使用buttonedit的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试在其中一列中用buttonedit创建一个gridcontrol。当用户单击按钮编辑时,弹出窗体以选择产品。当弹出窗口中的选择完成时,它会将DataRow从选择返回到主网格,如下所示。



但是当列失去焦点时,我写的值到列消失。





这里是我的代码,它创建了gridcontrol的数据和buttonedit的点击事件。

  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 =(发件人为ButtonEdit);
buttonEdit.Text = dr_return [URUNKOD]。ToString();

}

为什么值消失?我应该首先填写datatable并重新绑定吗?如何解决这个问题?

解决方案

看起来按钮编辑与主机网格没有紧密连接。看看是否可以将值分配给底层网格单元格或数据行行值。然后,它应该坚持。


I am trying to create a gridcontrol with buttonedit in one of the columns. 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.

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.

    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.

这篇关于如何在devexpress gridcontrol中使用buttonedit的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-20 21:48