473,587 Members | 2,258 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

2.0 DataGridViewCom boBoxColumn Problem.

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 the second query just returns 1
value to each combobox. So, in other words, for each textbox, the next
result of the second query puts 1 value in the corresponding combobox.

Here is my code... What the heck am I doing wrong????

cmd = frmMainForm.cnn Shared.CreateCo mmand
cmd.CommandText = "select ID, DateEntered, Officer, FireExtID, State, Notes,
FireExtIDNum from FireExtClearing House"
cmd.CommandType = System.Data.Com mandType.Text
da.SelectComman d = cmd
da.Fill(ds, "Checks")

CmdExt = frmMainForm.cnn Shared.CreateCo mmand
CmdExt.CommandT ext = "select ID, Name from FireExtinguishe rs"
CmdExt.CommandT ype = System.Data.Com mandType.Text

da.SelectComman d = CmdExt
da.Fill(dsExt, "Ext")

dgMain.DataSour ce = ds.Tables(0)
dgMain.Columns. Clear()

Dim dgColID As New DataGridViewTex tBoxColumn
dgColID.DataPro pertyName = "FireExtID"
dgColID.HeaderT ext = "Extinguish er ID"
dgColID.SortMod e = DataGridViewCol umnSortMode.Not Sortable
dgMain.Columns. Add(dgColID)

Dim dgColSelect As New DataGridViewCom boBoxColumn
With dgColSelect
..DataPropertyN ame = "ID"
..DataSource = dsExt.Tables("E xt")
..DisplayMember = "Name"
..ValueMember = "ID"
..HeaderText = "Extinguish ers in the database"
..SortMode = DataGridViewCol umnSortMode.Not Sortable
End With
dgMain.Columns. Add(dgColSelect )

Dec 29 '05 #1
1 3454
Hi,

"Shawn" <sh**********@c cci.org> wrote in message
news:ea******** *****@TK2MSFTNG P12.phx.gbl...
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 the second query just returns 1
vale to each combobox. So, in other words, for each textbox, the next sult
of the second query puts 1 value in the corresponding combobox.

Here is my code... What the heck am I doing wrong????

cmd = frmMainForm.cnn Shared.CreateCo mmand
cmd.CommandText = "select ID, DateEntered, Officer, FireExtID, State,
Notes, FireExtIDNum from FireExtClearing House"
cmd.CommandType = System.Data.Com mandType.Text
da.SelectComman d = cmd
da.Fill(ds, "Checks")

CmdExt = frmMainForm.cnn Shared.CreateCo mmand
CmdExt.CommandT ext = "select ID, Name from FireExtinguishe rs"
CmdExt.CommandT ype = System.Data.Com mandType.Text

da.SelectComman d = CmdExt
da.Fill(dsExt, "Ext")

dgMain.DataSour ce = ds.Tables(0)
dgMain.Columns. Clear()

Dim dgColID As New DataGridViewTex tBoxColumn
dgColID.DataPro pertyName = "FireExtID"
dgColID.HeaderT ext = "Extinguish er ID"
dgColID.SortMod e = DataGridViewCol umnSortMode.Not Sortable
dgMain.Columns. Add(dgColID)

Dim dgColSelect As New DataGridViewCom boBoxColumn
With dgColSelect
.DataPropertyNa me = "ID"
This should be a column from the "Checks" table that is a foreign key to the
"Ext" table, so:

..DataPropertyN ame = "FireExtID" ' or whatever the fk is
.DataSource = dsExt.Tables("E xt")
.DisplayMember = "Name"
.ValueMember = "ID"
Value- and DisplayMember should come from the "Ext" table and the
ValueMember column should be the pk, so that's ok.

HTH,
Greetings
.HeaderText = "Extinguish ers in the database"
.SortMode = DataGridViewCol umnSortMode.Not Sortable
End With
dgMain.Columns. Add(dgColSelect )

Dec 29 '05 #2

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

Similar topics

3
3266
by: philip | last post by:
I have a datagridview with some columns. One of them has been declared as a DatagridviewComboboxColumn The datasource of this column is a table of an Access Database. There is 13000 lines in this table, but only 3 fields. In runtime, when I click on this column, the combobox is very long to open, and each time I click on the combo box on...
3
22140
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. I wish to populate, by default, all of the ComboBoxes with the same list of three choices. How do I add the DataGridViewComboBoxColumn, and do I...
4
7552
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;
0
2937
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 and woefully misguided. public class SomeClass { private string name;
0
2203
by: Ken | last post by:
Hi I have a little application that does datavalidation. It supports dynamically loaded plugins (you drop a dll with a class implementing IValidator<Tin the same dir as the main application). All classes that implement this interface are shown in a drop down in a DataGridViewComboBoxColumn named Validator. By choosing the class to...
1
2139
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 created DataGridViewComboBoxColumn and hooked them up to BindingSources that populate them with the lookup table's value (in edit mode) When editing...
0
1979
by: =?ISO-8859-2?B?UmFmYbMgR2llemdhs2E=?= | last post by:
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();
0
1918
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.... Now the problem is when i change the value in the DataGridViewComboBoxColumn it is reloading the datagrid and pointing to another cell containing...
1
5311
by: =?Utf-8?B?RWQgQ29oZW4=?= | last post by:
I have tried to use the DataGridComboBoxColumn object with limited success. What I want to do is to create one new unbound column to be a combo box (so far, this has worked), populate it with items from the database (this also has worked). But, now I want to be able to have the user select one of the items in that combo box and fire off an...
0
7915
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main...
0
7843
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language...
0
8205
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. ...
0
8339
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
1
7967
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...
1
5712
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes...
0
5392
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert...
1
2347
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
1
1452
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.