Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / Windows Forms / WinForm General / January 2008

Tip: Looking for answers? Try searching our database.

Why is DataGridView.AutogenerateColumns not exposed in designer

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Crazy Cat - 30 Jan 2008 16:37 GMT
Does anyone know why this is not exposed in the designer?

Is it just me or is this a really stupid oversight?

I turn it on in code, but that doesn't prevent the designer from every
once in a while autogenerating columns on my datagridview. I can't
seem to predict when this'll happen -- for example, I've got my
datagridview's datasource set to a bindingsource -- I clear out the
unnecessary colums in the datagridview and start the application. All
is fine. However, on subsequent restarts, sometime I'll see that
columns have been autogenerated in the designer, even though in the
particular edit session, I never changed the datasource, or any
aspects of the bindingsource.

How to stop this -- it is ANNOYING!

Thanks,
Jack Jackson - 30 Jan 2008 18:40 GMT
>Does anyone know why this is not exposed in the designer?
>
[quoted text clipped - 11 lines]
>
>How to stop this -- it is ANNOYING!

I have run into the same problem.  I asked about this here a few
months ago but never received a response.

What I finally did was to create a subclass of DataGridView and set
AutoGenerateColumns = False in the constructor.
Crazy Cat - 30 Jan 2008 20:03 GMT
> On Wed, 30 Jan 2008 08:37:59 -0800 (PST), Crazy Cat
>
[quoted text clipped - 20 lines]
> What I finally did was to create a subclass of DataGridView and set
> AutoGenerateColumns = False in the constructor.

Thanks for your response Jack.

I tried this and yet it is still autogenerating the columns. It must
be something I'm doing.

I looked at my code and the only thing I can put it down to is that I
dynamically set the datasource
in the code, but I set autogeneratecolumns to false in the constructor
of the derived class and for
good measure in the grid. In design view I deleted the extraneous
columns, started the application
and all was good. As soon as I stopped debugging I notice that
magically the columns have been regenerated
in design mode.
Crazy Cat - 30 Jan 2008 20:11 GMT
> > On Wed, 30 Jan 2008 08:37:59 -0800 (PST), Crazy Cat
>
[quoted text clipped - 35 lines]
> magically the columns have been regenerated
> in design mode.

OK, this time I'm pretty sure it's nothing I'm doing. In design mode I
delete the extraneous columns. When I close the form and reopen it in
the designer the columns have been autogenerated. This is only
happening on one datagrid in my application.

WHAT THE HELL?

Sign me,

FRUSTRATED
Crazy Cat - 30 Jan 2008 20:30 GMT
> > > On Wed, 30 Jan 2008 08:37:59 -0800 (PST), Crazy Cat
>
[quoted text clipped - 46 lines]
>
> FRUSTRATED

OK, I found the solution --

Do not set DataSource and DataMember at design time -- set them at
runtime and all is fine.

Actually you might want to set them at design time to get the bindings
for your columns, but after setting the bindings CLEAR OUT THE
Datasource and Datamember properties and set them at runtime.

Rate this thread:







Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.