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 / June 2007

Tip: Looking for answers? Try searching our database.

How to access combo box properties of DataGridView combo column

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Steve Marshall - 26 Jun 2007 09:31 GMT
Hi,  I have an unbound DataGridView with just 1 column in it.  The
column is a combobox type, and I need to be able to attach the
datasource to it programmatically.  This is because it is a DataTable
that gets built dynamically at runtime.  But I can't see how to get at
the underlying combobox that "belongs" to the column.  Anyone know how
to do this?  It has to be in there somewhere!  There doesn't even seem
to be a DataGridViewComboBoxColumn object (or similar), so obviously I
am looking in the wrong direction.  Somebody please adjust my
headspace!
Kevin Spencer - 26 Jun 2007 13:08 GMT
You have a DataGridView with just 1 column in it, and it is "a combobox
type," but you say that there doesn't seem to be a
DataGridViewComboBoxColumn "object" - - what exactly do you think the
"combobox type" column in your DataGridView is? Well, apparently you do not
know, but it's a DataGridViewComboBoxColumn. You even got the name right! In
fact, there are several classes associated with this one:

DataGridViewComboBoxColumn
DataGridViewComboBoxCell
DataGridViewComboBoxEditingControl
DataGridViewComboBoxCell.ObjectCollection
DataGridViewComboBoxDisplayStyle

So, I'm scratching my head trying to figure out where the disconnect is,
here. My guess is that you are aware that the DataGridView has a Columns
Collection, which is a Collection of DataGridViewColumn instances, a Rows
Collection, which is a Collection of DataGridViewRow instances, and that
each row has a Collection of DataGridViewCell instances. Now, you'll notice
that in my list there is a DataGridViewComboBoxCell class.
DataGridViewComboBoxColumn inherits DataGridViewColumn, and
DataGridViewComboBoxCell inherits DataGridViewCell. This is so that you can
add a DataGridViewComboBoxColumn to a DataGridView, or any other type of
DataGridViewColumn-derived class. In other words, all you have to do is cast
it as a DataGridViewComboBoxCell to get at its unique properties.

Signature

HTH,

Kevin Spencer
Microsoft MVP

Printing Components, Email Components,
FTP Client Classes, Enhanced Data Controls, much more.
DSI PrintManager, Miradyne Component Libraries:
http://www.miradyne.net

> Hi,  I have an unbound DataGridView with just 1 column in it.  The
> column is a combobox type, and I need to be able to attach the
[quoted text clipped - 5 lines]
> am looking in the wrong direction.  Somebody please adjust my
> headspace!
Steve Marshall - 26 Jun 2007 13:56 GMT
Yeah, a Momentary Lapse of Reason, to quote Pink Floyd.  Sorry to
waste anyone's time.  I was originally trying to type
DataGridComboBoxColumn (without the 'View" in it), and of course there
ain't no such!  When I posted the message here, my brain must have
clicked into gear.  Yes, I have found all the objects and all is well
in combobox-column-land.  Thanks.

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.