Hello everyone,

Is it to possible to validate cells of datagridview using regular expression? Also i am loading datagridview using combo box i.e table names are provided in the combo box depending on the selection corresponding tables data will be loaded on to the grid view. And all the tables do not have same number columns. How to validate this. Please help me.

More clearly there will be multiple tables and cell validation shld happen dynamically based on the selected table. And also is it possible to validate all columns of a table against regular expression

Thank you

Edited 5 Years Ago by manugm_1987: n/a

Sure its possible to use Regular expressions. But you have to be specific what you have to validagte.
About columns checking, do you have to check if there is the correct number of columns to suit the number of columns of dataTables (dataSet)?

Best option is to use data binding. So no manual columns creation, but use DataSource property of DGV, this will automatically create columns (each time).
Just dont forget to set dataSource to null when re-setting new data to dgv.

Sure its possible to use Regular expressions. But you have to be specific what you have to validagte.
About columns checking, do you have to check if there is the correct number of columns to suit the number of columns of dataTables (dataSet)?

Best option is to use data binding. So no manual columns creation, but use DataSource property of DGV, this will automatically create columns (each time).
Just dont forget to set dataSource to null when re-setting new data to dgv.

Ya, i am binding my DGV to the datasource,I dont have to manually create columns. My problem is, since the DGV is bound to dataset this dataset may contain n number of tables. Each table will have diferent column name and different number of columns. I will load the DGV with the table selected by user in the combo box. Now when user select company table it may contain 4 columns, when user selects order table it may contain 6 columns. How can i validate cells of company table, order table depending on the selection.

Suppose say other table contains some 50 columns, it will be cumbersome job to validate each cell by its column name i.e dgv.columns["ID"]. So i need to have 50 if else statements to validate 50 columns. Is there any other method to implement like this kind of cell validation.

Thank you

Thank you for reply.

This article has been dead for over six months. Start a new discussion instead.