Advertisement

01.23.2008 at 05:44AM PST, ID: 23104231
[x]
Attachment Details

DataGridViewComboBoxColumn not displaying data as expected

Asked by graham_ball in .NET, C# Programming Language

Tags: , , ,

I'm generating a combobox in a datagridview using windows forms, but it doesn't display the data, only listviewItem{1}  (2 and 3).
Just can't see what I'm missing...
thanks,
Graham
Start Free Trial
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
27:
28:
29:
30:
31:
32:
33:
34:
DataGridViewComboBoxColumn comboboxColumn = new DataGridViewComboBoxColumn();
			comboboxColumn.DataPropertyName = "PRIORITY";
			comboboxColumn.HeaderText = "Priority";
			comboboxColumn.Name = "PRIORITY";
			comboboxColumn.DropDownWidth = 90;
			comboboxColumn.Width = 100;
			comboboxColumn.MaxDropDownItems = 3;
			comboboxColumn.FlatStyle = FlatStyle.Flat;
			comboboxColumn.SortMode = DataGridViewColumnSortMode.Automatic;
			string[] priorityData = new string[2];
			for (int i = 1; i <= 3; i++)
			{
				priorityData[0] = i.ToString();
				switch (i)
				{
					case 1:
						priorityData[1] = "High";
						break;
					case 2:
						priorityData[1] = "Medium";
						break;
					case 3:
						priorityData[1] = "Low";
						break;
					default:
						break;
				}
				ListViewItem itm = new ListViewItem(priorityData);
				itm.Selected = false;
				comboboxColumn.Items.Add(itm);
			}
			comboboxColumn.ValueMember = "Key";
			comboboxColumn.DisplayMember = "Value";
			dgvSoNInvestment.Columns.Add(comboboxColumn);
[+][-]01.23.2008 at 06:46AM PST, ID: 20723652

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]01.23.2008 at 06:59AM PST, ID: 20723770

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]01.23.2008 at 07:43AM PST, ID: 20724181

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]01.23.2008 at 08:17AM PST, ID: 20724570

View this solution now by starting your 7-day free trial. Setting up your free trial is quick, easy, and secure. We will return you to this solution, unlocked, when you're done.

 

About this solution

Zones: .NET, C# Programming Language
Tags: MS, C#, VS 2005, windows forms, C#
Sign Up Now!
Solution Provided By: graham_ball
Participating Experts: 3
Solution Grade: B
 
 
[+][-]02.03.2008 at 09:44PM PST, ID: 20812203

Experts Exchange has a courteous staff of administrators who help members get the most out of the website by means of administrative comments like this one.

Start your 7-day free trial to view this Administrative Comment or ask the Experts your question.

 
 
Loading Advertisement...
20080716-EE-VQP-32 / EE_QW_2_20070628