DataGridViewComboBoxColumn, selecting items in dropdownlist

G

Guest

Hi, I'm using in a DataGridView the DataGridViewComboBoxColumn
(VS2005-VB.NET). My problem: selecting items in the dropdownlist don't
behave like I want. Example: the dgv-dropdownlist shows: "Red, red, Green,
green, Black, black". Now the user selects the 'green' item. Then, first
'green' becomes visible as the cell's value, but when leaving the cell this
value changes to: 'Green'. This is not what I want. I selected and want the
item-value 'green'.

VS2005, VB.NET
Regards, Coen.
 
C

ClayB

Are you populating your dropdown items in the combobox from a
DataTable DataSource? If so, you might try setting
dataTable1.CaseSensitive = true to see if that affects this behavior.
It did for me.

===============
Clay Burch
Syncfusion, Inc.
 
L

Linda Liu [MSFT]

Hi Coen,

I performed a test on this issue and found that this problem exists when I
bind the DataGridViewComboBoxColumn to a DataTable, i.e. set the
DataGridViewComboBoxColumn's DataSource property to the DataTable and its
DisplayMember property to a column and its ValueMember property to another
column in the DataTable.

The DataTable has two columns: col1 and col2. There're 6 rows in the
DataTable as follows:

1 Red
2 red
3 Green
4 green
5 Black
6 black

Run the program and select 'green' from the drop down list of a
DataGridViewComboBoxCell. After the focus leaves the cell, the text in the
cell becomes 'Green'. It seems that the underlying data source, i.e. the
DataTable regards 'Green' to be equal to 'green'. After I set the
DataTable's CaseSensitive property to true as Clay suggests, the problem
disappears.

FYI, this problem doesn't exist if we add items to the
DataGridViewComboBoxColumn directly. For example,

this.Column1.Items.Add("Red");
this.Column1.Items.Add("red");
this.Column1.Items.Add("Green");
this.Column1.Items.Add("green");

This problem doesn't exist either on ComboBox, even if the DataTable's
CaseSensitive property is the default value--false.

Hope this helps.
If you have anything unclear, please feel free to let me know.


Sincerely,
Linda Liu
Microsoft Online Community Support

==================================================
Get notification to my posts through email? Please refer to
http://msdn.microsoft.com/subscriptions/managednewsgroups/default.aspx#notif
ications.

Note: The MSDN Managed Newsgroup support offering is for non-urgent issues
where an initial response from the community or a Microsoft Support
Engineer within 1 business day is acceptable. Please note that each follow
up response may take approximately 2 business days as the support
professional working with you may need further investigation to reach the
most efficient resolution. The offering is not appropriate for situations
that require urgent, real-time or phone-based interactions or complex
project analysis and dump analysis issues. Issues of this nature are best
handled working with a dedicated Microsoft Support Engineer by contacting
Microsoft Customer Support Services (CSS) at
http://msdn.microsoft.com/subscriptions/support/default.aspx.
==================================================

This posting is provided "AS IS" with no warranties, and confers no rights.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top