【问题标题】:datagrid cell validation and automatic sort - VB.NETdatagrid 单元格验证和自动排序 - VB.NET
【发布时间】:2012-08-19 21:34:01
【问题描述】:

我有问题...

我需要一个验证单元格 (ID) 的 VB 代码 - (我使用了事件 CellValidating),

这个值在datagrid中必须是唯一的...如果这个单元格的值是uniqe,那么在datagrid中按ID列对行进行排序。

例如,数据网格是:

ID          Name                
1           First
3           third

如果我输入 ID 值 3,则弹出 Messagebox.Show ("Error")...

但是,如果我在列 ID 中输入值 2,那么数据网格必须自动排序

这对排序有用吗 -> DataGridViewColumnSortMode.Automatic ??

谢谢

【问题讨论】:

    标签: vb.net sorting datagrid cell


    【解决方案1】:

    应该能够使用一个简单的 If Then 语句来完成这项工作。这个大纲应该能让你朝着正确的方向前进。

    If datagrid.ID = "your input" Then
    msgbox("This ID already exhists")
    ElseIf
    'code to add to datagrid
    'code to re-sort grid
    EndIF
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2021-12-29
      • 1970-01-01
      • 1970-01-01
      • 2014-07-26
      • 2011-01-27
      相关资源
      最近更新 更多