?
Solved

How can I cause a DataGridView Cell to begin edit mode when a user hits a numeric key?

Posted on 2008-10-08
9
Medium Priority
?
1,414 Views
Last Modified: 2008-10-22
If a user has a row selected I don't want them to have to double click to edit (there is only one column that will ever need to be edited anyway).  I want them to simply begin typing and have that certain cell (always the 5th column) in the current row to begin edit mode.  That way they can just use the keyboard and move from row to row editing this one column of data without every using the mouse.  Again, the other columns will never need to be edited, just this one.
0
Comment
Question by:David L. Hansen
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 5
  • 4
9 Comments
 
LVL 48

Expert Comment

by:jpaulino
ID: 22691270
Can you show the code you have ? Normally you don't need to double cick to start editing.
0
 
LVL 15

Author Comment

by:David L. Hansen
ID: 22713999
I have no code attempts.  I'm not sure where to begin.  All I have right now is the datagridview set to fullrowselect mode.  
Now, with that mode being set, the user only highlights a row (when using a single click) instead of editing...no problem so far, this behavior is what I want.  Currently then, the user can only enter edit mode on a single cell by double-clicking on it.  What I want to do is give the user an additional, alternative way of editing cells, in a quick, keyboard approach (ie. they begin typing when a row is highlighted and it automatically begins to edit the cell in column 5 of the current row).
0
 
LVL 48

Expert Comment

by:jpaulino
ID: 22727033
Let me see if I understood ...
You want to keep the selection to full row mode but when the user starts to type it writes on column 5. Is that it ?
0
NEW Veeam Agent for Microsoft Windows

Backup and recover physical and cloud-based servers and workstations, as well as endpoint devices that belong to remote users. Avoid downtime and data loss quickly and easily for Windows-based physical or public cloud-based workloads!

 
LVL 15

Author Comment

by:David L. Hansen
ID: 22732982
Yes, that's exactly what I want.
0
 
LVL 48

Accepted Solution

by:
jpaulino earned 2000 total points
ID: 22733205
You can force to select always the same column. Since it's in fullrowselect the user will not notice that and when you start to write, it starts on that colum.
 
Check this example:

    Private Sub DataGridView1_SelectionChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles DataGridView1.SelectionChanged
        Me.DataGridView1.CurrentCell = Me.DataGridView1(4, Me.DataGridView1.CurrentRow.Index)
    End Sub

Open in new window

0
 
LVL 15

Author Comment

by:David L. Hansen
ID: 22735179
I think we are on the right track...I like your solution; it doesn't do anything for me though.  I've incorporated the code and it runs without error.  However, when I select a row and begin typing, nothing happens...no errors no changes...nothing.  The row remains selected though.  Are we missing something?
0
 
LVL 48

Expert Comment

by:jpaulino
ID: 22735213
Have you add this code after fill the datagridview ?
Notice that I have used the column number 4 for this snippet and you have to choose the right one.
0
 
LVL 15

Author Comment

by:David L. Hansen
ID: 22735365
I added the code, changed the column number (with a zero based index the column I need is 5), updated the datagridview name and ran the program in debug mode.  The grid fills with data, I highlight a row, then begin typing...nothing happens.  Does it work for you?
0
 
LVL 48

Expert Comment

by:jpaulino
ID: 22736487
>> Does it work for you?
Sure :)  I always test the vode before post here.
Do you use some other code ? Can you show what you have so far ?
0

Featured Post

Prepare for your VMware VCP6-DCV exam.

Josh Coen and Jason Langer have prepared the latest edition of VCP study guide. Both authors have been working in the IT field for more than a decade, and both hold VMware certifications. This 163-page guide covers all 10 of the exam blueprint sections.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

When trying to find the cause of a problem in VBA or VB6 it's often valuable to know what procedures were executed prior to the error. You can use the Call Stack for that but it is often inadequate because it may show procedures you aren't intereste…
This article describes some techniques which will make your VBA or Visual Basic Classic code easier to understand and maintain, whether by you, your replacement, or another Experts-Exchange expert.
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…
Suggested Courses
Course of the Month13 days, 15 hours left to enroll

801 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question