473,394 Members | 1,811 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,394 software developers and data experts.

My first combobox in the datagrid :-(

why see my combobox not in datagrid with values(offen, closed) not to column
the 5?

Please help me!

This is my first combobox and i have no idea what i can to do.

My source:

private void button1_Click(object sender, System.EventArgs e)

{

ComboInTheGrid();

}

private void ComboInTheGrid()

{

// Create a table style that will hold the new column style

// that we set and also tie it to our customer's table from our DB

DataGridTableStyle tableStyle = new DataGridTableStyle();

tableStyle.MappingName = "tblFiBuPeriode";

DataTable dt = ds.Tables["tblFiBuPeriode"];
// make the dataGrid use our new tablestyle and bind it to our table

for(int i = 0; i < dt.Columns.Count; ++i)

{

if(i == 5)

{

DataGridComboBoxColumn ComboTextCol = new DataGridComboBoxColumn();
tableStyle.PreferredRowHeight = ComboTextCol.ColumnComboBox.Height + 2;

ComboTextCol.MappingName = "Status";

tableStyle.GridColumnStyles.Add(ComboTextCol);

ComboTextCol.ColumnComboBox.Items.Clear();

ComboTextCol.ColumnComboBox.Items.Add("Open");

ComboTextCol.ColumnComboBox.Items.Add("Close");

ComboTextCol.ColumnComboBox.DropDownStyle = ComboBoxStyle.DropDownList;

}

else

{

// Nothing

}

}

}

The datasource is the datasource from the hole datagrid that i have.

I have a datagrid with columns and i want in the last column a choice open
or close in my datagrid...it is this possible and how?

Thanks and i hope your understand my english :-)

Thanks

Michael

Nov 15 '05 #1
2 1612
Hi Michael,

DataGridTableStyle/DataGridColumnStyle setup should occur BEFORE the grid is
bound to a data source. In your case, it seems to be you are trying to set
up the combo box column upon a button click way after the grid has been
bound to the data source.

--
Dmitriy Lapshin [C# / .NET MVP]
X-Unity Test Studio
http://x-unity.miik.com.ua/teststudio.aspx
Bring the power of unit testing to VS .NET IDE

"Michael Schindler" <NO**********************@naviti.ch> wrote in message
news:eX**************@TK2MSFTNGP10.phx.gbl...
why see my combobox not in datagrid with values(offen, closed) not to column the 5?

Please help me!

This is my first combobox and i have no idea what i can to do.

My source:

private void button1_Click(object sender, System.EventArgs e)

{

ComboInTheGrid();

}

private void ComboInTheGrid()

{

// Create a table style that will hold the new column style

// that we set and also tie it to our customer's table from our DB

DataGridTableStyle tableStyle = new DataGridTableStyle();

tableStyle.MappingName = "tblFiBuPeriode";

DataTable dt = ds.Tables["tblFiBuPeriode"];
// make the dataGrid use our new tablestyle and bind it to our table

for(int i = 0; i < dt.Columns.Count; ++i)

{

if(i == 5)

{

DataGridComboBoxColumn ComboTextCol = new DataGridComboBoxColumn();
tableStyle.PreferredRowHeight = ComboTextCol.ColumnComboBox.Height + 2;

ComboTextCol.MappingName = "Status";

tableStyle.GridColumnStyles.Add(ComboTextCol);

ComboTextCol.ColumnComboBox.Items.Clear();

ComboTextCol.ColumnComboBox.Items.Add("Open");

ComboTextCol.ColumnComboBox.Items.Add("Close");

ComboTextCol.ColumnComboBox.DropDownStyle = ComboBoxStyle.DropDownList;

}

else

{

// Nothing

}

}

}

The datasource is the datasource from the hole datagrid that i have.

I have a datagrid with columns and i want in the last column a choice open
or close in my datagrid...it is this possible and how?

Thanks and i hope your understand my english :-)

Thanks

Michael


Nov 15 '05 #2
It is possible you set my code in the right form?

I try now more as one day for this solution and now i have no more patience

I have a siple code with a datagrin and into this datagrid i want a combobox
that the user can coise open or close...that is all...but i have many
problems
with this control into a datagrid and all exampels ar others as my code.

Thank

Michael

For test i have a button yes.

Later I make from this source a methode. If I start this form i start this
methode.
Nov 15 '05 #3

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

Similar topics

0
by: Gamze | last post by:
Hi, In my vb.net windows application ,i have combobox which is populated by sqlserver database table.When i select value from combobox ,value saved in to other table of my database and i use to...
1
by: Swadh | last post by:
Hi, I need urgent help on Windows Form datagrid. I have to Display a datagrid that has a textbox column and another one combo box column. I have two tables in my Access database as: Table 1:...
3
by: Bill C. | last post by:
Hello, I know this has been discussed a lot already because I've been searching around for information the last few weeks. I'm trying to implement a DataGridComboBoxColumn class. I've found...
2
by: john sutor | last post by:
Does anyone know how to create a combobox in a standard datagrid? I can create check boxes , but not the combobox
3
by: PeterZ | last post by:
G'day, After doing much searching and pinching bits of ideas from here there and everywhere I came up with a fairly 'clean' solution of including a comboBox into a dataGrid column. You can...
2
by: pei_world | last post by:
I want to implement a key hit with enter to dropdown a combobox that is in the datagrid. in this case I need to override its original behaviours. I found some codes from the web. Does anyone know...
3
by: TT (Tom Tempelaere) | last post by:
Hay there, I'm writing my own DataGridComboBoxColumn because .NET 1.1 does not have one (I hope .NET 2.0 supplies one). I based it on this article:...
1
by: John Doe | last post by:
Now i know how to manually add a combobox to a datagrid, but how would i handle the recordset below? ID | FirstName | LastName | Job -------------------------------- 1 |Joe | Smith |...
10
by: Doug Bell | last post by:
Hi I am still having problems with Tabbing through a DataGrid with a DataGridComboBox Column. I need to allow the User to Type the value into the ComboBox so consequently its ComboBoxStyle is...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
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: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
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,...
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
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...
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...

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.