473,386 Members | 1,958 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.

Datagridview: limit number of characters

Hi,

I have a simple application with a datagrid. It just gives a list of selected employees, and the user then enters a grade in a column for each employee. I have created the application which is fine, but a user has requested that when you enter a grade (that is valid), they want the system to move to the next employee.

What i need: only allow 1 character in a datagridview cell and if that charcter is valid (i.e. characters A to F) then to move to the next cell below.

Thanks
Jul 18 '07 #1
4 2725
kenobewan
4,871 Expert 4TB
Welcome to TSDN. What do you plan to do if it is not valid? Are you looking for validation or limiting of the field?
Jul 18 '07 #2
If it is not valid the cell doesn't change.
I currently use cellvalidating and cellvalidated procedures to achieve this when the user moves to the next cell (by the enter key or down arrow), but these events don't kick off until users manually move out of the cell
Jul 18 '07 #3
kenobewan
4,871 Expert 4TB
Please post your relevant code. Thanks.
Jul 18 '07 #4
Here is may code for those events:

Private Sub DGRegister_CellValidated(ByVal sender As Object, ByVal e As System.Windows.Forms.DataGridViewCellEventArgs) Handles DGRegister.CellValidated
DGRegister.Rows(e.RowIndex).Cells(e.ColumnIndex).V alue = Microsoft.VisualBasic.Strings.UCase(DGRegister.Row s(e.RowIndex).Cells(e.ColumnIndex).Value)
End Sub

Private Sub DGRegister_CellValidating(ByVal sender As Object, ByVal e As System.Windows.Forms.DataGridViewCellValidatingEve ntArgs) Handles DGRegister.CellValidating
Dim ValidEntry As Boolean
Dim txtCell As String, txtOldCell As String
Dim iC As Integer

ValidEntry = False
txtCell = UCase(e.FormattedValue)
For iC = 0 To iMaxCodes
If txtCell = Microsoft.VisualBasic.Strings.UCase(KeysAllowed(iC )) Then
ValidEntry = True
Exit For
End If
Next
If Not ValidEntry Then
e.Cancel = True
End If
End Sub
Jul 18 '07 #5

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

Similar topics

2
by: SJM | last post by:
In some VBA code I am building an SQL string to append a new record to a table. The string involves 40 fields. What I am finding is that it works with 39 fields but when I add 40 it fails with the...
3
by: ken | last post by:
Hi, I was wondering how the 4k table record limit is counted. I have access 2k. I text fields are 256 chars. Memo fields are not included in the calculation. What about yes/no fields would that be...
1
by: HopfZ | last post by:
Internet Explorer 6 bookmarklets(favlets) has size limit. And its size limit depend on the kind of code. For example, CODE A and CODE B (below) are both at their size limit. CODE A does not work...
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...
130
by: Daniel Manes | last post by:
I'm baffled. I have a column in a SQL Server Express database called "Longitude," which is a float. When I view the table in a DataGridView, some of the numbers, which only have two decimal places...
4
by: Alec MacLean | last post by:
Is anyone aware of a size limit imposed on the subject text when using the System.Net.Mail library? I'm getting problems of message not being recieved if the subject exceeds 15 chars. Thx
1
by: | last post by:
Hello everyone, I am using a textbox for dumping information generated by the file system watch object. I am having this problem that always at some stage new new information stops being entered...
3
by: rossmclean | last post by:
Hi, I am trying to add "x" number of DGV controls at run time. In my app the user selects a dir with a number of mdbs in it. They then select which dbs they want to run a common SQL against. ...
2
by: =?Utf-8?B?Q2hyaXMgRGF2b2xp?= | last post by:
I thought there was a limit of characters passed on the URL in asp.net of 1100 characters. I sent 1426 characters and it worked. Is there a limit of number of characters on the URL that you can...
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: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
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.