473,888 Members | 1,584 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

DataGrid:Textbo x - Enter Key not firing Validate

I have a datagrid (uggg) that I use and create the columns
programmaticall y...see below.
objCol = New DataGridTextBox Column
objCol.MappingN ame = "amount"
objCol.HeaderTe xt = "Amount"
objCol.Width = 60
objCol.Format = "C"
objDGTS.GridCol umnStyles.Add(o bjCol)
' create keypress, validating events for this textbox column only
Dim dgtb As DataGridTextBox = CType(objCol.Te xtBox, DataGridTextBox )
AddHandler dgtb.KeyPress, AddressOf Amount_KeyPress
AddHandler dgtb.Validating , AddressOf Amount_Validati ng
Everything seems to work great...except that the event "Amount_Validat ing"
does not fire when I use the "arrow keys" or the "enter key". It fires when
I use the "tab key" or use the mouse to click aournd on the grid. I'm
assuming this has something to do with "focus" or something like that.
Can anyone help me get this event to fire with the enter key/arrow keys?

TIA
-bruce duncan

Nov 21 '05 #1
6 3317
Override the IsInputKey method to get arrow keys fire keypress event as
such:

Protected Overrides Function IsInputKey(ByVa l keyData As
System.Windows. Forms.Keys) As Boolean
If keyData = Keys.Up OrElse keyData = Keys.Down OrElse _
keyData = Keys.Right OrElse keyData = Keys.Left OrElse _
keyData = Keys.Enter Then
Return True
End If
End Function

Bruce D expressed precisely :
I have a datagrid (uggg) that I use and create the columns
programmaticall y...see below.
objCol = New DataGridTextBox Column
objCol.MappingN ame = "amount"
objCol.HeaderTe xt = "Amount"
objCol.Width = 60
objCol.Format = "C"
objDGTS.GridCol umnStyles.Add(o bjCol)
' create keypress, validating events for this textbox column only
Dim dgtb As DataGridTextBox = CType(objCol.Te xtBox,
DataGridTextBox )
AddHandler dgtb.KeyPress, AddressOf Amount_KeyPress
AddHandler dgtb.Validating , AddressOf Amount_Validati ng
Everything seems to work great...except that the event "Amount_Validat ing"
does not fire when I use the "arrow keys" or the "enter key". It fires
when
I use the "tab key" or use the mouse to click aournd on the grid. I'm
assuming this has something to do with "focus" or something like that.
Can anyone help me get this event to fire with the enter key/arrow keys?

TIA
-bruce duncan


--
--------------------------------------------------
Christopher C. Bernholt
I.T. Research & Development
..NET Re-Engineering Team
R & L Carriers, Inc.
http://www.gorlc.com
--------------------------------------------------

Nov 21 '05 #2
That override is on the datagrid btw.

It happens that Bruce D formulated :
I have a datagrid (uggg) that I use and create the columns
programmaticall y...see below.
objCol = New DataGridTextBox Column
objCol.MappingN ame = "amount"
objCol.HeaderTe xt = "Amount"
objCol.Width = 60
objCol.Format = "C"
objDGTS.GridCol umnStyles.Add(o bjCol)
' create keypress, validating events for this textbox column only
Dim dgtb As DataGridTextBox = CType(objCol.Te xtBox, DataGridTextBox )
AddHandler dgtb.KeyPress, AddressOf Amount_KeyPress
AddHandler dgtb.Validating , AddressOf Amount_Validati ng
Everything seems to work great...except that the event "Amount_Validat ing"
does not fire when I use the "arrow keys" or the "enter key". It fires when
I use the "tab key" or use the mouse to click aournd on the grid. I'm
assuming this has something to do with "focus" or something like that.
Can anyone help me get this event to fire with the enter key/arrow keys?

TIA
-bruce duncan


--
--------------------------------------------------
Christopher C. Bernholt
I.T. Research & Development
..NET Re-Engineering Team
R & L Carriers, Inc.
http://www.gorlc.com
--------------------------------------------------

Nov 21 '05 #3
Something interesting...t he "right arrow" key fires the event...but none of
the other keys do??

-bruce
Nov 21 '05 #4
I'm new to VB.NET...
Where do I put the override function? I placed it on the top of my
form...but it didn't work (which I didn't think it would because I don't
understand how tell it to override for th datagrid).

-bruce
"Christophe r C. Bernholt" <cb*******@ATrl carriers.com> wrote in message
news:mn******** *************** @ATrlcarriers.c om...
That override is on the datagrid btw.

Nov 21 '05 #5
I created a new class (see below) and added it to my project. Now, I'm not
sure how I tell the datagrid on my form to use the new class I created...or
am I way off on what I'm supposed to be doing here in order to get the
override to work?

Public Class dgX
Inherits System.Windows. Forms.DataGrid
Protected Overrides Function IsInputKey(ByVa l keyData As
System.Windows. Forms.Keys) As Boolean
If keyData = Keys.Up OrElse keyData = Keys.Down OrElse keyData =
Keys.Right OrElse keyData = Keys.Left OrElse keyData = Keys.Enter Then
Return True
End If
End Function
End Class
"Christophe r C. Bernholt" <cb*******@ATrl carriers.com> wrote in message
news:mn******** *************** @ATrlcarriers.c om...
That override is on the datagrid btw.

Nov 21 '05 #6
You're on the right track. You can override the keydown on the
datagrid now and intercept the arrow keys. Now if you build your new
class, then right click in your tool box and select add/remove then
browse to the dll for your new class, it will add it to the toolbox and
you can use it in your application.

Bruce D :
I created a new class (see below) and added it to my project. Now, I'm not
sure how I tell the datagrid on my form to use the new class I created...or
am I way off on what I'm supposed to be doing here in order to get the
override to work?

Public Class dgX
Inherits System.Windows. Forms.DataGrid
Protected Overrides Function IsInputKey(ByVa l keyData As
System.Windows. Forms.Keys) As Boolean
If keyData = Keys.Up OrElse keyData = Keys.Down OrElse keyData =
Keys.Right OrElse keyData = Keys.Left OrElse keyData = Keys.Enter Then
Return True
End If
End Function
End Class
"Christophe r C. Bernholt" <cb*******@ATrl carriers.com> wrote in message
news:mn******** *************** @ATrlcarriers.c om...
That override is on the datagrid btw.


--
--------------------------------------------------
Christopher C. Bernholt
I.T. Research & Development
..NET Re-Engineering Team
R & L Carriers, Inc.
http://www.gorlc.com
--------------------------------------------------

Nov 21 '05 #7

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

Similar topics

0
1523
by: Tetet B via .NET 247 | last post by:
I'm using VB.Net and trying to retrieve the data in the textboxcell of a datagrid after a successful display (used Databind).User can either display data or enter data in the textbox. I canalways get the textbox object using either the Controls orFindControl method but it's always returning an empty *.Textinstead of the value displayed on the screen. Below are snippetsof my code - anybody there who can help me PLEASE? =====*.vb <edit mode...
1
4060
by: Agnes | last post by:
I need to limit the number of characters in the Textbox column in the datagrid. How can I do that ? Thanks
0
1459
by: awightma | last post by:
Hi, I have a datagrid with a number of textboxes on it. I want one column of my table to be visible=false because it contains the id of the record from the table. For some reason when I set visible=true on the aspx page I can access it no problem, but when I set visible=false the value that is returned is always equal to "" Dim testing8 As String = CType(e.Item.Cells(8).Controls(1),
3
7289
by: Mike L | last post by:
For a Data Grid in a Win Form, when the user selects a row and then presses the Enter key, how do I capture that the user pressed the enter key?
2
5386
by: Maziar Aflatoun | last post by:
Hi everyone, I have this DataGrid that I bind to a DataTable. However, instead of displaying the column 'Qty', I like to place it in a textbox and display the value of Qty as the default value for the TextBox. Any suggestions? <asp:datagrid id="DGShoppingCart" runat="server" Width="650" AutoGenerateColumns="False"> <Columns> <asp:BoundColumn DataField="ProductName" HeaderText="Product"
1
2687
by: Irishmaninusa | last post by:
Hello Everyone, I have a datagrid and have used a text box as way to allow a user to edit items in the grid. My question for you is how is it possible to write code for the text change event of the text box. I want to put in some validation and I don't want to use the validator controls because that seems to validate all controls that they are assoicated with in the grid and that is not the desired effect. If any one could help out...
1
1742
by: jason | last post by:
I've seen a few posts on this issue, but no clear solutions. I have a mulitiline textbox inside a datagrid. I use TemplateColumn to define as multiline with 3 rows. I have other field types like drop downs that have no issue displaying last values in edit mode with seemingly more complicated code. when I attempt to find my textbox with
4
1369
by: Sam | last post by:
Hi, This is driving me totally insane. I have two datagrid controls, and when I click on the first one its Enter event is called properly but the Enter event of the other one is being called straight after. I don't understand why... Here is my code if someone wants to have a look at that: Private Sub dgCtrl_Enter(ByVal sender As Object, ByVal e As System.EventArgs) Handles dgCtrl.Enter m_dgCtrlFocused = True
3
1718
by: kingflux | last post by:
Hello, and thank you in advance for any help you can provide. Each line in our datagrid control contains a product number, description, and a textbox for the user to enter a quantity-to-order. Users enter quantities (not necessarily on every line), click the Next button, and continue. Sometimes users return to a previous page, by clicking the Previous button, and see quantities that they did not enter. More often, users return to a...
0
11178
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...
0
10777
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 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...
0
10438
tracyyun
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...
0
9597
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...
0
7148
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5817
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
6014
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
4243
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
3251
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.