473,385 Members | 1,712 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,385 software developers and data experts.

Combo Box in .Net Data Grid

To anyone trying to solve the dropdown combo box navigation in a .net
grid problem, here is one solution - hey, it works:

We neet to trap key down and up (arrow) events and use them to
navigate the combo box rather than navigate the grid. Don't want to
be forced to use the mouse to navigate the combo box. So here is the
solution:

Create the following class which inherits the Combo box.
Public Class NoKeyUpCombo
Inherits ComboBox
Private WM_KEYUP As Integer = &H101
Const WM_KEYDOWN As Integer = &H100

Protected Overrides Function ProcessCmdKey(ByRef msg As Message,
ByVal keyData As Keys) As Boolean
need this function to be able to capture the Down/Up arrow
keys
''prevents the cell from changing so we can navigate the combo
box
Dim currentCell As DataGridCell
Dim iSel As Int16
Dim iMax As Int16
'System.Diagnostics.Debug.Write(keyData)
'System.Diagnostics.Debug.Write(keyData.ToString)
If Me.Items.Count < 1 Then
Return True
End If
Try
If keyData.ToString = "Down" Then
iMax = Me.Items.Count
If Me.SelectedIndex < iMax - 1 Then
iSel = Me.SelectedIndex + 1
Me.SelectedIndex = iSel
End If
End If
If keyData.ToString = "Up" And Me.SelectedIndex 0 Then
iSel = Me.SelectedIndex - 1
Me.SelectedIndex = iSel
End If
Catch ex As Exception
'Throw ex
Me.SelectedIndex = -1

End Try
End Function

Protected Overrides Sub WndProc(ByRef m As
System.Windows.Forms.Message)
If m.Msg = WM_KEYUP Or m.Msg = WM_KEYDOWN Then
'ignore keyup/down to avoid problem with tabbing &
dropdownlist;
Return
End If

MyBase.WndProc(m)

End Sub 'WndProc
End Class 'NoKeyUpCombo

'''hope this helps, -Peter

May 1 '07 #1
0 1093

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

Similar topics

2
by: kk | last post by:
Have 2 problems, any help is appreciated. Tab with Grids -------------- BL - fetching data from DB ( 5 secs - 10 rows) Grid Laod - 20 secs Grid Paint on tab change - 20 secs Problem: The...
1
by: kk | last post by:
I have 2 issues, please help ! 1st issue : -------------------------------------------------------- Loading Grid ------------ 1) creating new rows in a datatable and adding data a array...
1
by: gudia | last post by:
Two tables: Accounts and Companies Accounts (AcctID, AcctNmbr, AcctName, CompID) -- AcctID is PK and CompID is Foreign Key from Companies. Companies (CompID, CompName) -- CompID is PK. ...
4
by: Mike L | last post by:
I'm open for any suggestions on how to better program this. I want the user to select a license from a combo box, cboPrivilege and then the user will click the add button, then a record will be...
2
by: Brian Henry | last post by:
Hi, I have a data grid that is set up like this Page items displayed = 10 EnableViewState = false (i dont want to send large amounts of data over the internet!) CustomPaging = false...
3
by: Agnes | last post by:
in my combo box , as the user choose the display member , the grid will show related data However,as the user "key in the data" in the combox , and press 'enter' , the grid won't show related...
6
by: Ron L | last post by:
I have a dataset whose source is a SQL 2k stored procedure that I am trying to display in a datagrid. This datasource has 4 columns that I am interested in here, a text column and 3 value columns...
9
by: bill.jenner | last post by:
I have two related tables I wish to use in a grid. The second table has to drive the list of items apart of a combo box apart of one of the grids columns. Table 1 schema has columns ( . . . ....
1
by: pavanip | last post by:
Hi, I have a data grid control and I placed one combo box in that data grid and I am binding data to data grid combo box.When i run the application by default the combo box is not showing anything...
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: 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
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
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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
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,...

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.