Link to home
Start Free TrialLog in
Avatar of sgaggerj
sgaggerjFlag for United States of America

asked on

DataGridView combobox display

Hi all,

Here's another DataGridView question:

I have a column in my DataGridView that is defined as DataGridViewComboBoxCells.
The cell is databound to a table in my database and gets its values from a single column in that table.

There are presently ~65 items in that column and it will continue to grow to a max of about 95

My problem is that when the combobox is clicked and the elements are displayed for the user to choose, the entire list of elements are not displayed.
A single column that starts at the very top of the screen, and goes all the way down to the task bar is displayed, showing around 50 items.
There are no scrollbars and moving the mouse towards the bottom of the list does not scroll it down further.

What I would like to do is one of the following:

1) Add scrollbars to the list that is displayed and reduce it's height to something a bit more managable, similar to a dropdown list in excel that shows 10-15 items and has scrollbar on the side to access the rest of the items in the list.

OR

2) Add a filter to the combobox where if the user types 1 or 2 characters (ie 'F' or 'FL') the the list of elements is filtered to show only those starting with 'F' or 'FL'.

OR

3) Add an auto-suggest feature similar to that of a web-browser where if the user types in the part of the code, below the box the filtered list (similar to #2) is displayed (ie in the addressbar of a web browser, if you start to type in an address of a page already visited, it will auto-suggest possible pages that it has in cache.)

Any of these would be acceptable and greatly appreciated if someone can help me out.

TIA!

J

Avatar of noulouk
noulouk

Hi sgaggeri,

2) The way to achieve this is to select from the database or your DataSource the 1 or 2 letters (substring)  of each words you want to display and fill a ComboBox with those letters. Then when SelectedValue changed, you select the related words.
3) Follow this link to find a project about an auto completion CombobBox in VB.Net:
http://www.codeproject.com/vb/net/AutoCompleteComboBox.asp

Hope this helps.
Avatar of sgaggerj

ASKER

Hi noulouk,

that's an awesome example and I think it would pretty much cover what i'm trying to do - however.....

Many of the methods associated with comboboxes are not available under a DataGridViewComboBoxCell, such as

(taken from the code example you provided)

.SelectionStart
.Text
.SelectionLength
.FindString

Is there a way I could write those functions, adding to the functionality of the datagridview?
If so, where do I start?

J
SOLUTION
Avatar of noulouk
noulouk

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Private Sub Me_KeyPress(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles Me.KeyPress
        AutoComplete(Me, e, True)
End Sub

Sorry
ASKER CERTIFIED SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Sorry, it appears to be a Windows Forms 2.0  control so no problem.
awesome - that's pretty much what i'm looking for!!

thanks!

J