[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

AutoGenerateColumns= false not working

Posted on 2006-03-30
3
Medium Priority
?
980 Views
Last Modified: 2008-01-09
I am able to set up my datagridview fine.  I use
DgvCalls.AutoGenerateColumns = false;
so that I can programmatically add columns.  The column that I added works fine, however the columns of the datasource are still coming up.  what am I doing wrong?  Below is my code.

Thanks.
//parent table

DaCustomers = new SqlDataAdapter("select * from Customers", conn);

DaCustomers.Fill(data, "Customers");

//child table

DaCalls = new SqlDataAdapter("select * from Calls", conn);

DaCalls.Fill(data, "Calls");

//table with look up values to use in datagridview later

DaTblLkUp = new SqlDataAdapter("select * from tblLkUP", conn);

DaTblLkUp.Fill(data, "tblLkUp");

//relation

DataRelation relation = new DataRelation(" CustomersCalls",

data.Tables["Customers"].Columns["IDCall"],

data.Tables["Calls"].Columns["IDCall"],false);

data.Relations.Add(relation);

//BindSource1

BindSourceCustomers.DataSource = data;

BindSourceCustomers.DataMember = "Customers";

//BindSource2 relation in tables

BindSourceCalls.DataSource = BindSourceCustomers;

BindSourceCalls.DataMember = "CustomersCalls";

//DataGridView shows the related values of the parent table

DgvCalls.DataSource = BindSourceCalls;

DgvCalls.AutoGenerateColumns = false;

//Set up Column with the look up value

One of the colums is called RsnCall.  The main table stores 1, 2, 3 ,4....the second table stores the values to the codes "get info", "appointment", ect

DataGridViewComboBoxColumn Col1 = new DataGridViewComboBoxColumn();


Col1.HeaderText = "Reason Call";

Col1.DataPropertyName = "RsnCall";

Col1.DataSource = data1;

Col1.DisplayMember = "tblLkUp.Name_Lk";

Col1.ValueMember = "tblLkUp.ID_Lk";


Col1.FlatStyle = FlatStyle.Flat;



DgvCalls.Columns.Insert(1, Col1);

What am I doing wrong????
0
Comment
Question by:yanci1179
  • 2
3 Comments
 
LVL 3

Accepted Solution

by:
dabitbol earned 1500 total points
ID: 16336301
Well,

I tried your way and it's true, but try to invert your two lines:

DgvCalls.AutoGenerateColumns = false;
DgvCalls.DataSource = BindSourceCalls;

Worked on mine!
0
 

Author Comment

by:yanci1179
ID: 16336492
thanks, switched the lines and it worked!!  Do you know why?  Thanks alot!!
0
 
LVL 3

Expert Comment

by:dabitbol
ID: 16336883
Well, in .Net 2.0, it autibinds your DataSource, since the property is at true before then..

Thanks for the points
0

Featured Post

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction This article series is supposed to shed some light on the use of IDisposable and objects that inherit from it. In essence, a more apt title for this article would be: using (IDisposable) {}. I’m just not sure how many people would ge…
Introduction Although it is an old technology, serial ports are still being used by many hardware manufacturers. If you develop applications in C#, Microsoft .NET framework has SerialPort class to communicate with the serial ports.  I needed to…
Exchange organizations may use the Journaling Agent of the Transport Service to archive messages going through Exchange. However, if the Transport Service is integrated with some email content management application (such as an anti-spam), the admin…
Despite its rising prevalence in the business world, "the cloud" is still misunderstood. Some companies still believe common misconceptions about lack of security in cloud solutions and many misuses of cloud storage options still occur every day. …
Suggested Courses

873 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question