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 / July 2006

Tip: Looking for answers? Try searching our database.

How to change a DataGridViewTextBoxColumn to a DataGridViewComboBoxColumn?

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
nvx - 18 Jul 2006 20:14 GMT
Hi,
how can I change a DataGridViewTextBoxColumn to a
DataGridViewComboBoxColumn programmatically?

Thanks...

With regards
nvx
nvx - 19 Jul 2006 20:33 GMT
Hmm, I've experimented a bit with this thing again...

As I add a new column to a DataSet bound to a DataGridView, it leads to
automatic addition of one TextBox column into the DataGridView. After using

    DataGridViewCell cell = new DataGridViewComboBoxCell();
    DGV.Columns["colname"].CellTemplate = cell;

I encounter an error message "Value for the property CellTemplate has to
be of the Windows.Forms.DataGridViewTextBoxCell type or has to be
derived from this type." (I'm sorry for the translation, but the
original error message was not in English)

I wonder, am I able to change the column type upon it's automatic
creation? I guess not. How could I change the column type then? I should
definitely not add any new columns to the DataGridView as I'd have two
brand new columns instead of one then...

Maybe I could still create the column myself, remove the automatically
created one and set the data binding, but that doesn't seem to me as a
good solution. There must be a simple way how to do this...

Any ideas?

With regards
nvx

nvx napsal(a):
> Hi,
> how can I change a DataGridViewTextBoxColumn to a
[quoted text clipped - 4 lines]
> With regards
> nvx
edgarrolla@yahoo.com.br - 25 Jul 2006 14:36 GMT
Same problem over here! If you guys find any alternative way, please
don't forget to post it here! :D

> nvx napsal(a):
> > Hi,
[quoted text clipped - 5 lines]
> > With regards
> > nvx
Paul Jones - 25 Jul 2006 14:44 GMT
I had this problem in the past for a few times too. Then I stopped using
the DB designer in VS2005 and started writing my own code for working
with DB. This way I can define the type of a column as I wish before I
add it to the DataGridView and bind it to the DB table's column.

P.J.

edgarrolla@yahoo.com.br napsal(a):
> Same problem over here! If you guys find any alternative way, please
> don't forget to post it here! :D
[quoted text clipped - 8 lines]
>>> With regards
>>> nvx

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.