Print Page | Close Window

Extra Columns added to DataGridView

Printed From: IdeaBlade
Category: DevForce
Forum Name: DevForce Classic
Forum Discription: For .NET 2.0
URL: http://www.ideablade.com/forum/forum_posts.asp?TID=544
Printed Date: 11-Jun-2026 at 1:38pm


Topic: Extra Columns added to DataGridView
Posted By: Miszou
Subject: Extra Columns added to DataGridView
Date Posted: 13-Nov-2007 at 12:22pm
I have a DataGridView and DataGridViewBindingManager on a form. Using the "Configure Databindings" dialog, I have added 3 columns to the DGVBM. At this point, everthing is working fine...
 
However, if I change the type of one of the columns (in this case, to a DateTimePicker), I get a 4th textbox column bound to the same property as the modified column.
 
This additional column does not appear in the "Configure DataBindings" dialog, or in the "Edit Columns" dialog of the grid, and it is not mentioned anywhere in the designer.cs file!
 
However, during initialization, at the end of "InitializeComponent()", it appears to be added by the following line:
 
((System.ComponentModel.ISupportInitialize)(this.mEventDGVBM)).EndInit();
 
I have had a similar effect in several other places, and I have usually "fixed" the problem, by simply making the offending column invisible in the code, but I am not particularly happy doing this, for several reasons...
 
Unfortunately, I currently have a need to know how many columns are available in a grid (so that I can add a new row to the end of the grid if the user presses "tab" while on the last column/row) and the presence of extra invisible columns is making my code much more complicated than it needs to be!
 
Is this is a known problem, or is the presence of these extra runtime-created columns something that I have brought upon myself by not doing things properly?
 
Thank you.



Print Page | Close Window