Datagrid.RejectChanges() problem.

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Alpha Zero

    #1

    Datagrid.RejectChanges() problem.

    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?



  • Nicholas Paldino [.NET/C# MVP]

    #2
    Re: Datagrid.Reject Changes() problem.

    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.


    --
    - Nicholas Paldino [.NET/C# MVP]
    - nicholas.paldin o@exisconsultin g.com

    "Alpha Zero" <sandeepgiri1@h otmail.com> wrote in message
    news:ev4taadUDH A.2456@TK2MSFTN GP09.phx.gbl...[color=blue]
    > Hi!
    > I have a datagrid containing single column.
    > If user adds a new word, I want to check if this word does not contain[/color]
    any[color=blue]
    > 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[/color]
    added[color=blue]
    > to datagrid.
    >
    > How should I go about it?
    >
    >
    >[/color]


    Comment

    Working...