473,399 Members | 2,146 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,399 software developers and data experts.

ComboBox in DataGrid - Stuck! Help with Debugging!!

I've been trying to put a them, please help me out.

Here's the major parts of my code:
public Form1()
{
DataSet myDataSet = new DataSet("myDataSet");
DataTable testTable = new DataTable("table");
testTable.Columns.Add("Col1", typeof(Int32));
testTable.Columns.Add("Col2", typeof(String));
testTable.Rows.Add(testTable.NewRow());
myDataSet.Tables.Add(testTable);
dataGrid1.SetDataBinding(myDataSet, "table");
DataGridTableStyle ts1 = new DataGridTableStyle();
ts1.MappingName = "table";
DataGridColumnStyle boolCol = new DataGridBoolColumn();
boolCol.MappingName = "Col1";
boolCol.HeaderText = "ID #";
boolCol.Width = 150;
ts1.GridColumnStyles.Add(boolCol);
/************************************************** ***************************/
/********PROBLEM MIGHT BE IN AREA BETWEEN THESE
LINES*************************/
/************************************************** ****************************/
// Add a second column style.
DataGridComboBoxColumn comboCol = new DataGridComboBoxColumn();
comboCol.Format = "";
comboCol.FormatInfo = null;
comboCol.HeaderText = "ComboBox Field";
comboCol.MappingName = "Col2";
comboCol.Width = 125;
Rectangle rect = dataGrid1.GetCurrentCellBounds();
comboCol.ComboBox.Location = rect.Location;
comboCol.ComboBox.Show();
ArrayList ar1 = new ArrayList();
ar1.Add(new ComboBoxData("Apple"));
ar1.Add(new ComboBoxData("Banana"));
ar1.Add(new ComboBoxData("Carrot"));
comboCol.ComboBox.DataSource = ar1;
comboCol.ComboBox.DisplayMember = "Value";
comboCol.ComboBox.ValueMember = "Value";
/************************************************** ***************************/
/********PROBLEM MIGHT BE IN AREA BETWEEN THESE
LINES*************************/
/************************************************** ****************************/
ts1.GridColumnStyles.Add(comboCol);
dataGrid1.TableStyles.Add(ts1);
// Set task datagrid preferred height to combo box height
dataGrid1.PreferredRowHeight = comboCol.ComboBox.Height + 1;
}
public class DataGridComboBoxColumn : DataGridTextBoxColumn
{
private ComboBox comboBox;
public DataGridComboBoxColumn()
{
// Create combobox and force DropDownList style
this.comboBox = new ComboBox();
this.comboBox.DropDownStyle = ComboBoxStyle.DropDownList;
this.comboBox.BringToFront();
this.comboBox.Leave += new EventHandler(comboBox_Leave);
}
public ComboBox ComboBox
{get { return comboBox; }}
}

I basically got the DataGridComboBoxColumn class code from:
http://msdn.microsoft.com/msdnmag/is.../08/DataGrids/, and I only
listed some parts of it here. My problem is creating the 2nd column
which should have a ComboBox style. I think my data binding works,
but for some reason the ComboBox won't show up in the grid.

Thanks in Advance!!
Nov 16 '05 #1
1 2470
DNE
Can't help you with the DataGridComboBoxColumn however I can suggest a
simpler alternative.

Fully documented. Requires .NET framework 1.1 or later.

You will be allowed to use the libraries in any application - private or
commercial, and distribute them as part of your application, royalty-free.

E-mail me for your free copy: or*@s-e-a.com.au
Your acceptance of the license agreement will be required.

Ori
"anonymous" <si*******@hotmail.com> wrote in message
news:41*************************@posting.google.co m...
I've been trying to put a them, please help me out.

Here's the major parts of my code:
public Form1()
{
DataSet myDataSet = new DataSet("myDataSet");
DataTable testTable = new DataTable("table");
testTable.Columns.Add("Col1", typeof(Int32));
testTable.Columns.Add("Col2", typeof(String));
testTable.Rows.Add(testTable.NewRow());
myDataSet.Tables.Add(testTable);
dataGrid1.SetDataBinding(myDataSet, "table");
DataGridTableStyle ts1 = new DataGridTableStyle();
ts1.MappingName = "table";
DataGridColumnStyle boolCol = new DataGridBoolColumn();
boolCol.MappingName = "Col1";
boolCol.HeaderText = "ID #";
boolCol.Width = 150;
ts1.GridColumnStyles.Add(boolCol);
/************************************************** *************************
**/ /********PROBLEM MIGHT BE IN AREA BETWEEN THESE
LINES*************************/
/************************************************** *************************
***/ // Add a second column style.
DataGridComboBoxColumn comboCol = new DataGridComboBoxColumn();
comboCol.Format = "";
comboCol.FormatInfo = null;
comboCol.HeaderText = "ComboBox Field";
comboCol.MappingName = "Col2";
comboCol.Width = 125;
Rectangle rect = dataGrid1.GetCurrentCellBounds();
comboCol.ComboBox.Location = rect.Location;
comboCol.ComboBox.Show();
ArrayList ar1 = new ArrayList();
ar1.Add(new ComboBoxData("Apple"));
ar1.Add(new ComboBoxData("Banana"));
ar1.Add(new ComboBoxData("Carrot"));
comboCol.ComboBox.DataSource = ar1;
comboCol.ComboBox.DisplayMember = "Value";
comboCol.ComboBox.ValueMember = "Value";
/************************************************** *************************
**/ /********PROBLEM MIGHT BE IN AREA BETWEEN THESE
LINES*************************/
/************************************************** *************************
***/ ts1.GridColumnStyles.Add(comboCol);
dataGrid1.TableStyles.Add(ts1);
// Set task datagrid preferred height to combo box height
dataGrid1.PreferredRowHeight = comboCol.ComboBox.Height + 1;
}
public class DataGridComboBoxColumn : DataGridTextBoxColumn
{
private ComboBox comboBox;
public DataGridComboBoxColumn()
{
// Create combobox and force DropDownList style
this.comboBox = new ComboBox();
this.comboBox.DropDownStyle = ComboBoxStyle.DropDownList;
this.comboBox.BringToFront();
this.comboBox.Leave += new EventHandler(comboBox_Leave);
}
public ComboBox ComboBox
{get { return comboBox; }}
}

I basically got the DataGridComboBoxColumn class code from:
http://msdn.microsoft.com/msdnmag/is.../08/DataGrids/, and I only
listed some parts of it here. My problem is creating the 2nd column
which should have a ComboBox style. I think my data binding works,
but for some reason the ComboBox won't show up in the grid.

Thanks in Advance!!

Nov 16 '05 #2

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

Similar topics

1
by: Samuel Hon | last post by:
Hi I'm a bit stuck with a SELECT query. This is a simplified version of what I need. I've had a look in a few books and online but I'm definitely missing something. I'm trying to avoid looping...
1
by: Optimus | last post by:
When I got vs.net 2005 Beta 2 installed in my PC, It was getting trouble with debugging in 2003. When I pressed F5 it said "Unable to start debugging on the web server. Could not start ASP.NET...
3
by: dmalhotr2001 | last post by:
Hi, I have a datagrid hypothetically with this data: id | text | link ------------------------------- 1 | first row | delete button 2 | second row | delete button ...
2
by: John Dalberg | last post by:
I hsve an ASP.NET app whch hangs when I start it with debugging and the CPU usage is 100%. Starting without debugging works fine. Any ideas? -- John Dalberg
1
by: Bruce | last post by:
Hi, there, I meet a problem about comboBox binding. -------------------- Database: Northwind Tables: 1) Products 2) Categories I create a form (named "form1") to edit the record from...
4
by: jon f kaminsky | last post by:
Hi- I've seen this problem discussed a jillion times but I cannot seem to implement any advice that makes it work. I am porting a large project from VB6 to .NET. The issue is using the combo box...
9
by: lostnewmexico | last post by:
This one has me at whit's end. In order for this to make sense, I will have to lay out the "facts" to get a hypothesis. There is no easy way to explain this. Environment: VC2005. MFC...
1
by: t.kleczek | last post by:
Hi. I have a problem with debugging in Dev C++ 4.9.9.2 Whenever I try to debug the console c++ program the following message pops up: "Your project does not have debbuging information, do you...
2
by: kulet | last post by:
"2nd post as i noone could do it" Hi guys! Got stuck with this.. I have a chunks of text separated with blanc line. All I need is to take every last 3 lines of that text before the blanc line...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
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: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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
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...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

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.