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

Datagridview columns keep appearing

I have a form with a datagridview and I set the columns that I want on the
grid. Whenever I close the form in the form designer and then open it back
up, it will pull in all of the columns from the binding source. I have to
manually edit the columns every time and remove all of the unwanted ones.
What is going on?
Jun 12 '07 #1
3 2106
I am not sure but it sounds to me like the values from your datasource are
being grabed at design time and are then being serialized into your
designer.cs file.

When user controls are displayed at design time, visual studio is creating
instances of those controls. If you are loading data durring construction of
the control the designer will see those values and serialize them into the
code DOM (Dont quote me on this, it is just what I have observed).

To see if this is happening just open up your design.cs file and see if the
data is being included in your code. If this is what is going on try moving
the code that is creating the databinding into an if statement that checks
the this.DesignMode variable.

if(!this.DesignMode){
// do databinding here.
}
Jeremy Shovan
http://www.jeremyshovan.com

"Brooke" <tb******@hotmail.comwrote in message
news:uQ**************@TK2MSFTNGP02.phx.gbl...
>I have a form with a datagridview and I set the columns that I want on the
grid. Whenever I close the form in the form designer and then open it back
up, it will pull in all of the columns from the binding source. I have to
manually edit the columns every time and remove all of the unwanted ones.
What is going on?

Jun 12 '07 #2
I checked the code and it has the following

this.dataGridViewLookup.AutoGenerateColumns = false;

this.dataGridViewLookup.Columns.AddRange(new
System.Windows.Forms.DataGridViewColumn[] {

this.reviewID,

this.projectID,

this.drawingID,

this.reviewDescription});

Cannot find the problem...

"Jeremy Shovan" <je***********@student.neumont.eduwrote in message
news:D6**********************************@microsof t.com...
>I am not sure but it sounds to me like the values from your datasource are
being grabed at design time and are then being serialized into your
designer.cs file.

When user controls are displayed at design time, visual studio is creating
instances of those controls. If you are loading data durring construction
of the control the designer will see those values and serialize them into
the code DOM (Dont quote me on this, it is just what I have observed).

To see if this is happening just open up your design.cs file and see if
the data is being included in your code. If this is what is going on try
moving the code that is creating the databinding into an if statement that
checks the this.DesignMode variable.

if(!this.DesignMode){
// do databinding here.
}
Jeremy Shovan
http://www.jeremyshovan.com

"Brooke" <tb******@hotmail.comwrote in message
news:uQ**************@TK2MSFTNGP02.phx.gbl...
>>I have a form with a datagridview and I set the columns that I want on the
grid. Whenever I close the form in the form designer and then open it
back up, it will pull in all of the columns from the binding source. I
have to manually edit the columns every time and remove all of the
unwanted ones. What is going on?



Jun 12 '07 #3
Brook,

Are the columns reviewID, projectID, drawingID, reviewDescription the
columns that you expected to see or are they being added automatically be
the designer?

"Brooke" <tb******@hotmail.comwrote in message
news:Oa**************@TK2MSFTNGP05.phx.gbl...
>I checked the code and it has the following

this.dataGridViewLookup.AutoGenerateColumns = false;

this.dataGridViewLookup.Columns.AddRange(new
System.Windows.Forms.DataGridViewColumn[] {

this.reviewID,

this.projectID,

this.drawingID,

this.reviewDescription});

Cannot find the problem...

"Jeremy Shovan" <je***********@student.neumont.eduwrote in message
news:D6**********************************@microsof t.com...
>>I am not sure but it sounds to me like the values from your datasource are
being grabed at design time and are then being serialized into your
designer.cs file.

When user controls are displayed at design time, visual studio is
creating instances of those controls. If you are loading data durring
construction of the control the designer will see those values and
serialize them into the code DOM (Dont quote me on this, it is just what
I have observed).

To see if this is happening just open up your design.cs file and see if
the data is being included in your code. If this is what is going on try
moving the code that is creating the databinding into an if statement
that checks the this.DesignMode variable.

if(!this.DesignMode){
// do databinding here.
}
Jeremy Shovan
http://www.jeremyshovan.com

"Brooke" <tb******@hotmail.comwrote in message
news:uQ**************@TK2MSFTNGP02.phx.gbl...
>>>I have a form with a datagridview and I set the columns that I want on
the grid. Whenever I close the form in the form designer and then open
it back up, it will pull in all of the columns from the binding source.
I have to manually edit the columns every time and remove all of the
unwanted ones. What is going on?



Jun 12 '07 #4

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

Similar topics

3
by: thomasp | last post by:
I know this is a vague question, but I am not sure what information to give. I am using VB2005 beta and the datagridview is pulling data from one of three tables in an Access database. For some...
3
by: Bob | last post by:
Thinking two things, 1- Creating a userControl -yeah you guessed it, a multi column drop down combobox - I've looked at several articles and did not find what I need, one that's bindable and that...
1
by: Rich | last post by:
Hello, I am reading data from a sql server table that is under replication. This table has the replicatin GUID column that is generated with replicatin. I am reading the data from a...
7
by: Mitchell S. Honnert | last post by:
Is there an equivalent of the DataGrid's DataGridTableStyle for the DataGridView? If not, is there an easy way to duplicate the DataGridTableStyle's functionality for the DataGridView? Here's...
3
by: connected | last post by:
I'm having difficulty with populating a DataGridView control with data correctly. It works with a single class, for example... class MyClass { private string _propertyOne; private string...
2
by: Stephen Costanzo | last post by:
I have: Public Class test Private displayValue As String Private dbType As Integer Property Display() As String Get Return displayValue End Get
7
by: =?Utf-8?B?TG9zdEluTUQ=?= | last post by:
Hi All :) I'm converting VB6 using True DBGrid Pro 8.0 to VB2005 using DataGridView. True DBGrid has a MultipleLines property that controls whether individual records span multiple lines. Is...
2
by: mrstrong | last post by:
Gday, I have a datagridview that I am creating the columns programatically which all seems to work fine. I have a couple of dropdown boxes, so I have set the editMode= EditOnEnter. Now my...
6
by: Miro | last post by:
Sorry for the cross post. I am stuck. I have a datagridview for poker rounds. Basically there are 3 columns in this datagridview. "Round" "SmallBlind" "BigBlind" I have an issue when I tab...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
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...
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
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
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...

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.