473,387 Members | 1,517 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

Problem with Value in DataGridViewComboBoxColumn

I have:

protected void InitControls()
{
gvProfile.AutoGenerateColumns = false;

DataTable dtProfile = new DataTable("KFS");
// dodajemy kolumny
foreach(DataGridViewColumn dc in gvProfile.Columns) {
DataColumn ndc = new DataColumn();
ndc.ColumnName = dc.Name;
dtProfile.Columns.Add(ndc);
}

foreach (KeyValuePair<string, stringkfs in dicKFS) {
DataRow drow = dtProfile.NewRow();
drow["KFS_KOD"] = kfs.Key;
drow["KFS_NAZWA"] = kfs.Value;
dtProfile.Rows.Add(drow);
}

DataTable dtGFS = new DataTable("GFS");

// i ustawiamy liste dla Combo
List<ItemlItem = new List<Item>();
foreach (KeyValuePair<string, stringgfs in dicGFS) {
Item item = new Item();
item.ItemID = Convert.ToInt32(gfs.Key);
item.ItemName = gfs.Value;
lItem.Add(item);
}
GFS.DisplayMember = "ItemName";
GFS.ValueMember = "ItemID";
GFS.DataPropertyName = "Item";
GFS.DataSource = lItem;

gvProfile.DataSource = dtProfile;

if(_iPXX != -1) SetData(_iPXX);
}
when Item is:

class Item
{
private int itemID;
private string itemName;

public int ItemID
{
get { return this.itemID; }
set { this.itemID = value; }
}

public string ItemName
{
get { return this.itemName; }
set { this.itemName = value; }
}
}

When I'm trying after Init set:

dgvr.Cells["GFS"].Value = 2;

Combo doesn't react on my setting.
How can I set DataGridViewComboBoxColumn with effect ?


May 25 '07 #1
0 1966

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Shawn | last post by:
I am trying to use a DataGridView to display one column of textboxes with a single value from a query and then next to it have a combobox that displays results from another query. What happens is...
3
by: Rain County | last post by:
I am programmatically building and populating a table and then making it the data source for a dataGridView. I want to add a column to the dataGridView which will be a DataGridViewComboBoxColumn. ...
4
by: John | last post by:
Hi, I've been trying to populate a DataGridViewComboBoxColumn with objects. The object is defined as : private struct manufactItem { public string name; public Guid? man_id;
4
by: Matt | last post by:
I have been searching all over the web for a way to sort a DataGridView based on the actual text being shown in a ComboBox column as opposed to the underlying value (an ID in this case). Can anyone...
0
by: Simon Tamman | last post by:
How do other people get around having to define the ValueMember in a DataGridViewComboBoxColumn when binding to a list of business objects? I'm currently doing the following, and it feels wrong...
1
by: sklett | last post by:
I have a DataGridView bound to a custom business object. The business object has 2 attributes that are FKs to a lookup table (think HairColorID, EyeColorID, etc) For these 2 columns I have...
0
by: ajey | last post by:
hi all! Im doing a windows application (C#), i have a datagridview bound from a Sql database in which i want one column to be ComboBox.I use DataGridViewComboBoxColumn and bind that column value.......
0
by: news.microsoft.com | last post by:
Hello- I'm having a dickens of a time trying to set the value on a DataGridViewComboBoxColumn. I actually have two DataGridViewComboBoxColumns in my datagrid view. First, I'm setting up the...
0
by: gyanendar | last post by:
Hi All, I am using DataGridview and there is a Combobox column is present in the datagrid. I am binding the DataGridViewComboboxcolumn with a DataSource. DataGridViewComboBoxColumn cmbInstType...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.