HighTechTalks DotNet Forums  

DataGridViewComboBoxColumn

Dotnet Distributed Applications microsoft.public.dotnet.distributed_apps


Discuss DataGridViewComboBoxColumn in the Dotnet Distributed Applications forum.



Reply
 
Thread Tools Search this Thread Display Modes
  #1  
Old   
Dianna
 
Posts: n/a

Default DataGridViewComboBoxColumn - 03-08-2006 , 01:02 PM






Hi,

I have created a dropdown in my grid using the below code. It only needs to
display 2 values. The below allows me to acheive this, however, I want to be
able to have the first item be the default item. In a real combobox I would
just set the selectedIndex =0. It does not seem to be that easy to do in
this case, or intuitive. There is no selectedIndex, selectedItem, text,
etc. I even tried to work with the DataGridViewComboBoxCell, but again, not
very intuitive. This should not be complicated.

Can Anyone help me out here, All i want the dropdown to do is on load to
have the first item visible, currently the below loads with no items
selected, user has to select manually.

'Add Internal External DropDown
Dim cboCol As New DataGridViewComboBoxColumn
cboCol.Items.AddRange(New Object() {"Internal", "External"})
cboCol.Name = "cboCol"
Me.dgAvail.Columns.Add(cboCol)

Thanks,Dianna

Reply With Quote
  #2  
Old   
Roberto Nannuccci
 
Posts: n/a

Default Re: DataGridViewComboBoxColumn - 07-11-2006 , 08:15 AM






Hi there,
use this:




Dim ComboBoxColumn As New DataGridViewComboBoxColumn()
Dim myValues As String() = {"Internal", "External"}
With ComboBoxColumn
.Items.AddRange(myValues)
.DefaultCellStyle.NullValue = "Internal"
End With




Regards,

Roberto Nannucci
(nanna)



*** Sent via Developersdex http://www.developersdex.com ***

Reply With Quote
Reply




Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

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

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.4
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.