PC Review


Reply
Thread Tools Rate Thread

How to access combo box properties of DataGridView combo column

 
 
Steve Marshall
Guest
Posts: n/a
 
      26th Jun 2007
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!

 
Reply With Quote
 
 
 
 
Kevin Spencer
Guest
Posts: n/a
 
      26th Jun 2007
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.

--
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

"Steve Marshall" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> 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!
>



 
Reply With Quote
 
Steve Marshall
Guest
Posts: n/a
 
      26th Jun 2007
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.

 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Datagridview, Combo-box column: Dropdown on Autocomplete? Dan Microsoft Dot NET Framework Forms 1 4th Feb 2009 03:01 AM
Beginners question - DataGridView with a combo box column =?Utf-8?B?Qi4gQ2hlcm5pY2s=?= Microsoft Dot NET Framework Forms 1 26th Sep 2007 06:38 PM
How do I paint the combo box dropdown button in a datagridview column jermny@gmail.com Microsoft VB .NET 1 11th Sep 2006 03:45 PM
How to get a DataGridView column to show as combo box. bill.jenner@gmail.com Microsoft VB .NET 9 30th Nov 2005 07:17 AM
Store non-bound combo column as combo's control source? Nick Mirro Microsoft Access Forms 5 1st Sep 2003 03:19 AM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 07:13 PM.