【问题标题】:Dynamically check the validation status of a cell in DataGrid动态检查 DataGrid 中单元格的验证状态
【发布时间】:2021-07-23 10:33:39
【问题描述】:

我有一个 dataGrid,其中有一列与双变量绑定。

                <DataGrid Grid.Row="2" HeadersVisibility="Column" Name="ConsigneGrid" AutoGenerateColumns="False">
                <DataGrid.Columns>
                    <DataGridTextColumn Binding="{Binding CALIBRATEUR, StringFormat=F3}" ClipboardContentBinding="{x:Null}" Header="Consigne" Width="*"/>
                </DataGrid.Columns>
            </DataGrid>

我想在动态提交之前检查当前单元格值的有效性并激活下一行的编辑模式。

我尝试使用 PreviewTextInput 事件。但我只有新的输入字符。

之后,我尝试在 currentcell 上使用 IsValid 属性,但它没有更新。

有没有办法检查单元格的有效性(确保值是双倍的)。

【问题讨论】:

    标签: wpf data-binding datagrid


    【解决方案1】:

    我有办法确保在提交之前进行验证。

    我已经对每次按键进行了预检查。

        private void Grid_Resultat_PreviewTextInput( object sender, TextCompositionEventArgs e )
        {
            e.Handled = !( Information.IsNumeric( e.Text ) || e.Text == "." || e.Text == "," || e.Text == "-" );
        }
    

    谢谢! F.

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2011-10-27
      • 2019-06-12
      • 2011-08-07
      相关资源
      最近更新 更多