dataGridView2 is interferring with dataGridView1...

  • Thread starter Thread starter trint
  • Start date Start date
T

trint

Hi,
I have dataGridView1 with a DataSource (categoriesBindingSource).
I didn't use the vs.net workbench to bind the second datagridview
(dataGridView2).
I used this code:

bindingSource1.DataSource = GetData("Select id, parent_id, name FROM
categories where parent_id = '" + dgData1 + "' and active = 1 order by
sort_order asc");
dataGridView2.DataSource = bindingSource1;
From the Select statement, the columns are created on the fly in
dataGridView2.
I can't go to properties and create the columns I really want to have
since they are in the
Select statement. I can't make the Id column invisible (I want it
invisible because I only want the name column to show).

I need help in figuring out how to format the columns or gain control
over the columns generated on the fly by the Select statement in
dataGridView2 because right now it's not the way I want them.
Any help is appreciaed.
Thanks,
Trint
 
Hi,
I have dataGridView1 with a DataSource (categoriesBindingSource).
I didn't use the vs.net workbench to bind the second datagridview
(dataGridView2).
I used this code:

bindingSource1.DataSource = GetData("Select id, parent_id, name FROM
categories where parent_id = '" + dgData1 + "' and active = 1 order by
sort_order asc");
dataGridView2.DataSource = bindingSource1;


dataGridView2.
I can't go to properties and create the columns I really want to have
since they are in the
Select statement. I can't make the Id column invisible (I want it
invisible because I only want the name column to show).

I need help in figuring out how to format the columns or gain control
over the columns generated on the fly by the Select statement in
dataGridView2 because right now it's not the way I want them.
Any help is appreciaed.
Thanks,
Trint

I figured it out. After the dataGridView2 is bound with the select
statement, THAT is when
to make the "unnamed" columns visible=false.

Here is the code:
bindingSource1.DataSource = GetData("Select id, parent_id, name FROM
categories where parent_id = '" + dgData1 + "' and active = 1 order by
sort_order asc");
dataGridView3.DataSource = bindingSource1;
dataGridView3.Visible = true;
//this.dataGridView3.DataSource = ds.Tables[0];
this.dataGridView3.Columns[0].Visible = false; //id
this.dataGridView3.Columns[1].Visible = false; //
parent_id

Trint
 
Back
Top