|
-
May 17th, 2009, 07:03 AM
#1
DataGridViewComboBoxColumn selection disappears
Hello,
I am using DataGridViewComboBoxColumn as a column of DataGridView.
I have assigned data source as a List<myObject> and i am able to see all values in dropdown.
Now, for any Key Press it always select and display first element of list and but the selected value disappear as focus is taken away from the cell.
For e.g the comboBox list contains A, B, C & D. Now user presses key 'B' then it display 'B' as expected but if user presses 'E' then it display 'A' as selected and very strangely the selection disappears as focus looses from the cell.
What should i do not to display any selected value if it not in list?
-
July 15th, 2010, 10:55 PM
#2
Re: DataGridViewComboBoxColumn selection disappears
Hi, did you ever solve this problem?
I'm having a very similar issue - clicking on the text portion of a DataGridViewComboBoxColumn (which has its DataSource set) will appear toselect the first value from the set. But when the combo loses focus, the value reverts to empty; you have to actually drop down the combo and click on the value in the list for it to be really selected.
I'd be very interested to hear whether you managed to prevent the auto-select, or whether it's possible to prevent the auto-selecteded value from reverting on focus loss.
Cheers,
JimbO
-
October 3rd, 2010, 07:56 PM
#3
Re: DataGridViewComboBoxColumn selection disappears
I just came back to this with a fresh head and solved it as follows ...
Code:
protected override void OnEditingControlShowing(DataGridViewEditingControlShowingEventArgs e)
{
base.OnEditingControlShowing(e);
DataGridViewComboBoxEditingControl combo = e.Control as DataGridViewComboBoxEditingControl;
if (combo != null)
{
combo.SelectedIndex = -1;
}
}
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|