Datagrid.RejectChanges() problem.

  • Thread starter Thread starter Alpha Zero
  • Start date Start date
A

Alpha Zero

Hi!
I have a datagrid containing single column.
If user adds a new word, I want to check if this word does not contain any
character except A-Z and this word doesn't exists in previous rows .
If it exists, then user should be informed and this word should not be added
to datagrid.

How should I go about it?
 
Alpha,

You would need to do two things. First, I would add a constraint to the
column indicating that it is the primary key. This would prevent the column
from having duplicate values in it.

As for only allowing A-Z, that's a little harder. The DataColumn
doesn't support regular expressions. What you could do is add an event
handler for when a row is added. When it is, run the contents of the column
through the following regular expression (without quotes) "[A-Z]+". This
will allow only those characters any number of times.

Hope this helps.
 
Back
Top