什么是数据网格视图中行的单元格选择的正则表达式 [英] What is regex for cell selection of a row in datagridview

查看:90
本文介绍了什么是数据网格视图中行的单元格选择的正则表达式的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个包含5列的datagridview。根据选择的第一列,我想跳过验证。在下面的代码中,它不是hapenning。错误显示为没有选择行。



 validator =  new 正则表达式( @  ^ [0-9] {0} [0-9A-Z] $); 
if (!validator.IsMatch(dataGridView1.Text))
errors.AppendLine( 从网格中选择订单号);





如何解决这个问题?

解决方案

);
if (!validator) .IsMatch(dataGridView1.Text))
errors.AppendLine( 从网格中选择订单号);





如何解决这个问题?


你应该改变验证条件下午:



  if (!(dataGridView1.CurrentCell.ColumnIndex = =  0 && dataGridView1.SelectedCells.Count >   0 )&&!验证器。 IsMatch(dataGridView1.Text))
errors.AppendLine( 从网格中选择订单号);


I have a datagridview with 5 columns. Based on first column selected I want to skip validation. In the following code, it is not hapenning. The error is shown as if no row is selected.

validator = new Regex(@"^[0-9]{0}[0-9A-Z]$");
           if (!validator.IsMatch(dataGridView1.Text))
               errors.AppendLine("Select order No. from grid");



How to solve this?

解决方案

"); if (!validator.IsMatch(dataGridView1.Text)) errors.AppendLine("Select order No. from grid");



How to solve this?


You should change the validation condition like bellow:

if ( !(dataGridView1.CurrentCell.ColumnIndex  == 0 && dataGridView1.SelectedCells.Count > 0) && !validator.IsMatch(dataGridView1.Text))
    errors.AppendLine("Select order No. from grid");


这篇关于什么是数据网格视图中行的单元格选择的正则表达式的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆