保留 DevExpress Xtragrid 单元格中输入的值

发布于 2024-08-18 23:12:08 字数 135 浏览 7 评论 0原文

我在我的 C#.net Windows 应用程序中使用 DevExpress Xtragrid 控件。

我在网格的第一个单元格中输入一些值,如果我转到第二个单元格,第一个单元格中输入的值就会消失。

如何保留单元格中输入的值?

I am using DevExpress Xtragrid control in my C#.net windows application.

I enter some value into the first cell of the grid and if i go to second cell , the value entered in the first cell disappears.

How to retain the value entered in the cell ?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

提笔书几行 2024-08-25 23:12:08

我假设您将其用于 gridView (Xtragrid) 中的未绑定列,第一步是确保转到列属性,并将 UnboundType 属性值更改为您想要的数据类型要进入该列,下面的示例使用double

CustomUnboundColumnData 事件分配给您的 gridView。确保声明一个类级别变量(在下面的代码示例中名为 _userEnteredData)来保存您输入到 gridView 中的值,然后添加以下代码段,但请确保更改名称以匹配您的 gridView 和变量名称:

类级别变量声明:

private double _userEnteredData = 0;

现在的事件:

private void gridView1_CustomUnboundColumnData(object sender, DevExpress.XtraGrid.Views.Base.CustomColumnDataEventArgs e)
{
    if (e.Column == gridColumn_YourColumn && e.IsSetData)
    {
        _userEnteredData = Convert.ToDouble(e.Value);
    }
    else if (e.Column == gridColumn_YourColumn && e.IsGetData)
    {
        e.Value = _userEnteredData;
    }
}

我希望这会有所帮助。

您可以从这里获取更多详细信息:
http://documentation.devexpress.com/#WindowsForms/CustomDocument1477

I am assuming that you are using this for an unbound column in a gridView (Xtragrid), first step is make sure to go to the column properties, and change the UnboundType property value to the datatype that you will be entering into that column, example below uses double.

Assign the CustomUnboundColumnData event to your gridView. Make sure that you declare a class level variable (named _userEnteredData in code sample below) to hold the value that you are entering into your gridView, then add the following piece of code, but make sure that you change the names to match your gridView and variable names:

Class level variable declaration:

private double _userEnteredData = 0;

Now the event:

private void gridView1_CustomUnboundColumnData(object sender, DevExpress.XtraGrid.Views.Base.CustomColumnDataEventArgs e)
{
    if (e.Column == gridColumn_YourColumn && e.IsSetData)
    {
        _userEnteredData = Convert.ToDouble(e.Value);
    }
    else if (e.Column == gridColumn_YourColumn && e.IsGetData)
    {
        e.Value = _userEnteredData;
    }
}

I hope this helps.

You can get further details from here:
http://documentation.devexpress.com/#WindowsForms/CustomDocument1477

感情废物 2024-08-25 23:12:08

几种可能性:

  • 检查编辑列的 FieldName 属性。也许存在拼写错误,因此网格不会将您输入的值传递给
  • 绑定到列的基础数据源属性,该属性必须具有公共设置器。如果只有 getter,网格也无法存储输入的值,
  • 请检查网格列中的 ColumnOptions.ReadOnly 属性 - 必须设置为 false

希望这有帮助

Few possibilities:

  • check FieldName property of edited column. Maybe there is a typo, so grid does not pass your entered value to underlying datasource
  • property that is bound to column must have public setter. If there is only getter, grid also won't be capable to store entered value
  • check ColumnOptions.ReadOnly property in grid column - must be set to false

Hope this helps

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文