Windows Develop Bookmark and Share   
 index > Windows Forms Data Controls and Databinding > How do I enable typing in the combo box cell?
 

How do I enable typing in the combo box cell?

I did everythingas it is describled under point 26 inSticky: Windows Forms Data Controls and Databinding FAQ. However, typing data into a ComboBox field does not work properly.

I set updataGridView1_CellValidating anddataGridView1_EditingControlShowing in the same way as described.

What I get is as follows:
I can type some text into the ComboBox field.
When I leave the field, the newly typed text is added to the ComboBox' Items list.

But...
the typed text disappears, after leaving the ComboBox field. And if I start typing in a ComboBox field in the "new line" (the line marked with the '*') and then hit tab, enter or whatever the focus gets set to the next column, the text disappears and no new line is generated. In a normal text field the line marked with the '*' would change to a pencil as soon as you type a letter. This doesn't happen when typing into the ComboBox' Edit field.
If I select the newly typed text out of the ComboBoxes drop down list (where it is available then), the '*' immediately directly turns to a pencil and a new linewith a '*' gets generated.

Am I missing something?
wannabe_2  Sunday, February 01, 2009 8:04 PM

Hi wannabe,

The FAQ just shows how to enable typing in the ComboBox. This give us a method to achieve typing in the comboboxCell.

It adds your item to the combobox to avoid the error, and then we need to choose the item that we have typed in the drop down list or set the dataGridView.CurrentCell.Value tomaintain the string like the following:

DataGridViewCellValidatingEventArgs e)

// if bound, add the value to the dataSource

If the row is a new row, set the value will not cause adding a new new row. So we need to add a row to the dataGridView manually.

Best regards,

Ling Wang


Please remember to click “Mark as Answer�on the post that helps you, and to click “Unmark as Answer�if a marked post does not actually answer your question. This can be beneficial to other community members reading the thread.
Ling Wang  Sunday, February 08, 2009 7:39 AM

Hi wannabe,

The FAQ just shows how to enable typing in the ComboBox. This give us a method to achieve typing in the comboboxCell.

It adds your item to the combobox to avoid the error, and then we need to choose the item that we have typed in the drop down list or set the dataGridView.CurrentCell.Value tomaintain the string like the following:

DataGridViewCellValidatingEventArgs e)

// if bound, add the value to the dataSource

If the row is a new row, set the value will not cause adding a new new row. So we need to add a row to the dataGridView manually.

Best regards,

Ling Wang


Please remember to click “Mark as Answer�on the post that helps you, and to click “Unmark as Answer�if a marked post does not actually answer your question. This can be beneficial to other community members reading the thread.
Ling Wang  Sunday, February 08, 2009 7:39 AM

You can use google to search for other answers

Custom Search

More Threads

• DataRowState not changing to modified state
• Auto commit binding handler
• SQL Server Instance Not Known
• datagrid
• Totals row in datagridview
• Arbitrary child controls of DataGridViewRow
• Resetting values in DataGrid
• Datarelations and costraints
• why is this wrong
• A simple combobox question