473,728 Members | 1,598 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Datagrid Column Validation

ZS
Hi,
How can i validate user input in a datagrid ?
I want a column to accept just numeric values. If the user enter Text then
the changes must be rejected and the value set to waht it was earlier.
Thanks in advance
-ZS

Dec 6 '05 #1
3 1899
ZS wrote:
Hi,
How can i validate user input in a datagrid ?
I want a column to accept just numeric values. If the user enter Text then
the changes must be rejected and the value set to waht it was earlier.
Thanks in advance
-ZS


You will have to override the DataGridTextBox Column and handle it in the
keypress event. There may be a way to drill down and handle the event
without having to create your own class, but I can't think of where to
do that off the top of my head.

Chris
Dec 6 '05 #2
ZS


"ZS" wrote:
Hi,
How can i validate user input in a datagrid ?
I want a column to accept just numeric values. If the user enter Text then
the changes must be rejected and the value set to waht it was earlier.
Thanks in advance
-ZS

Dec 6 '05 #3
ZS
Hi Chris,
Thanks for your reply. The DataColumn constructor has a way to specify
the type of the data that it can accpet so we jusy specify it there instead
of a Keypress event.
-ZS

"Chris" wrote:
ZS wrote:
Hi,
How can i validate user input in a datagrid ?
I want a column to accept just numeric values. If the user enter Text then
the changes must be rejected and the value set to waht it was earlier.
Thanks in advance
-ZS


You will have to override the DataGridTextBox Column and handle it in the
keypress event. There may be a way to drill down and handle the event
without having to create your own class, but I can't think of where to
do that off the top of my head.

Chris

Dec 6 '05 #4

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

Similar topics

0
1050
by: Mike | last post by:
I was wondering, can you use a validation control to valid user input from a DataGrid control? Example: let say you are editing one of row. before you update the data store, you valid the row and column that was edit. i just need to know how to write the set value for the validation controlToValidate property? i was thinking something like DataGrid.Column(0).Cell(0).ID will return the control id.
9
1739
by: Lina | last post by:
Hi, Can anyone tell me if it is possible to add link buttons to a datagrid that has its source set to a datatable that i have created? i.e i want the user to be able to select a room from various comboboxes and textboxes on my form. when they are satisfied they press OK. the row is then displayed in my datagrid. I now automaticcaly want 2 link buttons to appear next to the row that allows the user to delete the row or edit it.
0
4412
by: JR | last post by:
Hello, Does anyone know how you can prevent a row full of 'null' values from being added to the datagrid when a user hits the delete key, deleting the word (null) which represents the default value of 'null'? Here's a simple way to reproduce this problem: 1) Add a datagrid to a winform 2) Put this code into the Form1_Load event and run it.
5
3246
by: Chris | last post by:
Based upon some prevoius postings on what to do for adding a 'add' row to a datagrid I utilize the footer to create the 'add' row. The only issue is that I have it sharing the 'UpDate_Command' and I use an argument to difference between an 'edit' vs. and 'add. But since I have field validation on both 'footer' and 'edit' columns I can't submit my edits since the footer validation kicks in.If I take the validation off then the both work fine...
4
2976
by: David Colliver | last post by:
Hi all, I am having a slight problem that hopefully, someone can help me fix. I have a form on a page. Many items on the form have validation controls attached. Also on this form are linkbuttons which must not cause validation. I have found a setting "causeValidation" to disable the validation. Also on the page, I have a datagrid that I will edit lines on. I can click
5
4562
by: cwbp17 | last post by:
Hi all, Have a datagrid that displays the price column of a table. Went to the Datagrid's Property builder and set the 'Data Formatting expression' for the PRICE column to {0:c}, so that the dollar sign, the comma, and the decimal are included (i.e. $44,644.48) Managed to update the price column of the datagrid back to the database, as long as, the user doesn't delete the dollar sign (in the 0 position).
5
2056
by: Tina | last post by:
the Edit, Update, Cancel, and Delete buttons in my datagrid are causing validation elsewhere on the page. I want to specify that these buttons should not cause validation but they have no design time property of causevalidation. How can I keep them from causing validation? Thanks, T
0
1221
by: Jeremiah Adams | last post by:
I am having two issues with the Datagrid and I hope that someone can help me out with them. 1) Printing. I pulled the code for sending the control to a printer off the msdn site. It works for the most part but will not print all the information contained in the control. For example, If the datagrid contains enough rows that the scroll bars become active and a user has to scroll down to display all the data the controll will only print...
1
1254
by: Tom | last post by:
I have seen articles saying that validating the data a user enters into a datagrid is difficult, because it is not the datagrid itself that does the validation, but rather textboxes that are in the cells. The article then says that it is best to validate the datatable behind the grid using row or column changing events. I have a few questions about this. If I am to use row or column data changing events on the
4
10700
by: Roger | last post by:
I have a datagrid and would like to know what even fires when a cell is changed? I want to know when the user changes a cell and moves to the next. I have some code that needs to be done to make sure entry is valid? Thanks, Rog
0
8899
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8757
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,...
0
9418
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
9196
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,...
0
8124
agi2029
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...
1
6712
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
4790
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
3235
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
3
2160
bsmnconsultancy
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.