CombodropDown in DataGridView

I

Ira

HI guys, I have a problem with adding a combo to a datagridview.
Here is my script:
dataGridView2.Columns.Clear();

PortTable = new DataTable();

PortTable.Columns.Add("Column1").DataType = typeof(string);

PortTable.Columns.Add("Column2").DataType = typeof(string);


PortTable.Columns.Add("Column3").DataType = typeof(string);

PortTable.Clear();

dataGridView2.DataSource = null;

newRow["Column1"] ="1";

newRow["Column2"] = "2";

DataGridViewComboBoxColumn comboboxColumn = new
DataGridViewComboBoxColumn();

comboboxColumn.DataPropertyName = "ptitle";

comboboxColumn.HeaderText = "Column3";



comboboxColumn.Items.Add("1");

comboboxColumn.Items.Add("2");

comboboxColumn.Items.Add("3");

????How could I add this combo to the datagrid with these items????

PortTable.Rows.Add(newRow);

dataGridView2.DataSource = PortTable;

Any help appreciated
 
J

Justin Dutoit

Hi. I don't know some of the terms you're using, but I thought
myGrid.Controls.Add(newControl) is the general idea, yes?

Justin
 
I

Ira

Thank you so much for replay:
I used one of hte samples from msdn, and getting this error:
Error 1 The type or namespace name 'Title' could not be found (are you
missing a using directive or an assembly reference?).
What does it mean? Any idea?


Angel J. Hernández M. said:
Hope this helps

http://msdn.microsoft.com/en-us/library/system.windows.forms.datagridviewcomboboxcolumn.aspx

http://www.getquotes-it.com/Articles/Using-the-DataGridViewComboBoxColumn.htm


Regards,


--
Angel J. Hernández M
MCP,MCAD,MCSD,MCDBA
Microsoft MVP
http://msmvps.com/blogs/angelhernandez
***************************************************
Technical Solution Architect
http://www.customware.net



Ira said:
HI guys, I have a problem with adding a combo to a datagridview.
Here is my script:
dataGridView2.Columns.Clear();

PortTable = new DataTable();

PortTable.Columns.Add("Column1").DataType = typeof(string);

PortTable.Columns.Add("Column2").DataType = typeof(string);


PortTable.Columns.Add("Column3").DataType = typeof(string);

PortTable.Clear();

dataGridView2.DataSource = null;

newRow["Column1"] ="1";

newRow["Column2"] = "2";

DataGridViewComboBoxColumn comboboxColumn = new
DataGridViewComboBoxColumn();

comboboxColumn.DataPropertyName = "ptitle";

comboboxColumn.HeaderText = "Column3";



comboboxColumn.Items.Add("1");

comboboxColumn.Items.Add("2");

comboboxColumn.Items.Add("3");

????How could I add this combo to the datagrid with these items????

PortTable.Rows.Add(newRow);

dataGridView2.DataSource = PortTable;

Any help appreciated
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top