473,386 Members | 1,766 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

How to validate a cell of datagridview in vb.net

Hi,
I have a datagridview on my form.There is a column of roll no in the datagridview.
I want that whenever user presses anyother key than a number key(ex:1,2,3,4....)than immediately i should get a messagebox that only numbers allowed.
I have tried the below code on datagridView Cellvalidation event but its not working.
Please suggest on what event and how can i do such validation.
Expand|Select|Wrap|Line Numbers
  1. If GridView2.Item(2,   GridView2.CurrentCell.RowIndex).Selected = True Then
  2.  If e.ColumnIndex = 3 Then
  3.    If Not IsNumeric(e.FormattedValue) Then
  4.        GridView2.Rows(e.RowIndex).ErrorText = _
  5.             "Please Insert only numbers."
  6.              e.Cancel = True
  7.    End If
  8.  End If
  9. End If
  10.  
  11.  
Oct 4 '11 #1
0 1535

Sign in to post your reply or Sign up for a free account.

Similar topics

0
by: Ryan Liu | last post by:
Hi, I want to validate the cell value before commit it -- changing the cell from edit mode(text box, DateTimePicker) to view mode. This happens when I click on other cell. Which event I can...
1
by: Morten Snedker | last post by:
How do I the value of a cell in a datagridview, before it is updated? I wish to validate the "visible" value, not the actual value (cell/row hasn't been updated yet). Thanks in advance. ...
0
by: None | last post by:
Hi, I'm using DataGridView in my Windows Forms project. I need to know how we can insert an image into the specified cell . I tried with the following code.
0
by: Dave | last post by:
I have a datagridview I call the CellValidating event and if the the cell does not validate I want to reset the cell to a default value. My code actually executes this statement: ...
1
by: BisterBooster | last post by:
Hi, Can someone help me for next problem How to for using ENTER key to move to the right cell instead of the TAB key Many thanks in advance Marc.
0
by: vbt | last post by:
I am new to using the DataGridView and I have read most everything I can find on this subject. But obviously I am not see the hole picture. I am trying to update a data base using the...
7
by: Ryan | last post by:
I have a DataGridView which displays numeric (Int32) data from an underlying database. I want the numbers to be displayed in numeric format "#,###" (with commas). I want to also limit the user so...
5
by: TheSteph | last post by:
Hi ! I have a DataGridView with a Date (DateTime) Column. When a user edit the cell and change the date I woulk like to allow him to write "081501" and programmatically transform the entered...
0
by: systeko | last post by:
Hello, I have one little problem which make me crazy. I've made application (for Windows) in Visual C#. On one panel I've got datagridview control which is not bind to database, I populate it...
0
by: priyamtheone | last post by:
I'm trying to make a datagridview column to act like a datetimepicker column (C#.Net 2005). These are the behaviours that the dgv should have: 1) Initially all the cells of the dtp column should be...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
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,...
0
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...
0
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,...
0
jinu1996
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...

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.