473,847 Members | 1,472 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Datagrid.Reject Changes() problem.

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?

Nov 15 '05 #1
1 2474

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]
- ni************* *@exisconsultin g.com

"Alpha Zero" <sa**********@h otmail.com> wrote in message
news:ev******** ******@TK2MSFTN GP09.phx.gbl...
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?

Nov 15 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

by: Roel | last post by:
I need help to format the column and detect any change on the datagrid. My source code is: dim da as SqlDataAdapter dim ds as DataSet dim dtSource as DataTable dim conn as SQLConnection = New SQLConnection(......)
by: Saso Zagoranski | last post by:
Hi again! I have two DataSets... I add some data to both of the dataset and the I call: dataAdapter1.Update(dataSet1); dataAdapter2.Update(dataSet2); if there is an exception in any of the two dataset I want ALL the data to be discarded, so I call: try
by: Alex K. | last post by:
I am using datagrid bound to a datatable: DataTable dt = ...; MyGrid.DataSource = new DataView(dt); Now I am trying to intercept delete operation, when user highlights a row and presses delete key. For this, I am using dt.RowDeleting event: private void dt_RowDeleting(object sender, DataRowChangeEventArgs e) {
by: DanB | last post by:
I want to asked the user if he is sure before deleting a row in a datagrid. I've created an event handler for the underlying table using the RowDeleting Event. If the user responds that he does not want to delete the row then I think I am supposed to throw an exception. But the rowstate is changed to deleted anyway. I thought throwing the exception would prevent this.
by: excelleinc.com | last post by:
Hello, I know that this question was here quite a few times but I was wondering if anyone atually found a solution/work around for it. I'm trying to prevent users from deleting certain rows in datagrid. This rows are specified in rownumber property. To do this I have implemented custom datagrid that looks like this: Class DGCustom
by: Geoff | last post by:
Hi Can anybody suggest how to get round the following problem? I have a form (form A for the sake of argument) which accepts data to be put into a DataTable. If the cancel button is pressed, I call RejectChanges to prevent the inputted data being passed to the DataTable. However, I also have a button on the form which calls another form (which I'll refer to as form B) which can also populate the table. In this form there is also a...
by: Ryan Liu | last post by:
Can someone give a sample to prevent a row from being deleted in a datatable? I tried e.Row.RejectChanges(); in dt_RowDeleting() but seems does not work. I need verify if there other data using data in this row before actually remove it from datagrid. I can certainly control with Delete button. But if I want to allow the user to use Del key on the keyboard, I lost this kind control.
by: Ryan Liu | last post by:
Hi, If a DataGrid.DataSource is an IList, not a DataTable, is there a way similar to dt.AcceptChanges(), dt.RejectChanges()? Thanks a lot! Ryan Liu
by: gtyler | last post by:
When you make changes to a DataGrid a picture of a Pencil appears on the right hand side. As I understand it, the DataSource is not updated until you move off that row and the Pencil disappears. If one of my users were to close the form without remembering to press the “Update Database” button then the changes would be lost. So I wrote a procedure for the On Closing Event that checks for Modified rows, and if there are it prompts the user to...
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.