Visual Basic .NET Forums  
Click here to advertise with us

Go Back   Visual Basic .NET Forums > Components & Controls > Grids > Winforms Grids

Winforms Grids Discussion related to grid controls of all types for Winforms

VB.NET Forums Newsletter Signup:
Email address:


Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 07-08-2009, 1:42 PM
VB.NET Forum Enthusiast
.NET Framework: .NET 3.0 (VS 2005/2008)
 
Join Date: May 2008
Location: Spain
Posts: 82
Reputation: 25
J Trahair is on a distinguished programming path ahead
Default Having a drop-down cell on datagrid

Is there a way of giving a cell a drop down combobox with a small number of choices in it, eg. choosing a currency symbol? In VB6 there was BuildCombo etc.

Thank you.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #2 (permalink)  
Old 07-08-2009, 2:42 PM
VB.NET Forum Miyagee
.NET Framework: .NET 2.0
 
Join Date: Nov 2007
Location: Kent, UK
Age: 39
Posts: 497
Reputation: 166
InertiaM I'm the one to askInertiaM I'm the one to askInertiaM I'm the one to askInertiaM I'm the one to askInertiaM I'm the one to askInertiaM I'm the one to ask
Default

Copied from a recent post by JohnH :-

Code:
Dim cell As New DataGridViewComboBoxCell
cell.Items.Add("A")
cell.Items.Add("B")
Me.DataGridView1.Item(col, row) = cell
__________________
Always parameterize your queries - read more here
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #3 (permalink)  
Old 07-08-2009, 3:05 PM
JohnH's Avatar
VB.NET Forum Moderator
.NET Framework: .NET 3.5 (VS 2008)
 
Join Date: Dec 2005
Location: Norway
Age: 37
Posts: 10,173
Reputation: 1273
JohnH has a reputation beyond reputeJohnH has a reputation beyond reputeJohnH has a reputation beyond reputeJohnH has a reputation beyond reputeJohnH has a reputation beyond reputeJohnH has a reputation beyond reputeJohnH has a reputation beyond reputeJohnH has a reputation beyond reputeJohnH has a reputation beyond reputeJohnH has a reputation beyond reputeJohnH has a reputation beyond repute
Default

Just add a Combobox column to the DataGridView when you configure its columns.
__________________
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #4 (permalink)  
Old 07-08-2009, 4:08 PM
VB.NET Forum Miyagee
.NET Framework: .NET 2.0
 
Join Date: Nov 2007
Location: Kent, UK
Age: 39
Posts: 497
Reputation: 166
InertiaM I'm the one to askInertiaM I'm the one to askInertiaM I'm the one to askInertiaM I'm the one to askInertiaM I'm the one to askInertiaM I'm the one to ask
Default

Can we clarify - is this question about a single cell, or a whole column?
__________________
Always parameterize your queries - read more here
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #5 (permalink)  
Old 07-08-2009, 4:13 PM
VB.NET Forum Enthusiast
.NET Framework: .NET 3.0 (VS 2005/2008)
 
Join Date: May 2008
Location: Spain
Posts: 82
Reputation: 25
J Trahair is on a distinguished programming path ahead
Default

This will be for all cells in a given column, except where there is no value in column 2 in that row (for example).
Eg. column 8 has the ComboBox if column 2 is valid.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #6 (permalink)  
Old 07-08-2009, 4:21 PM
VB.NET Forum Miyagee
.NET Framework: .NET 2.0
 
Join Date: Nov 2007
Location: Kent, UK
Age: 39
Posts: 497
Reputation: 166
InertiaM I'm the one to askInertiaM I'm the one to askInertiaM I'm the one to askInertiaM I'm the one to askInertiaM I'm the one to askInertiaM I'm the one to ask
Default

Sorry, my mistake then - I took "giving a cell a drop down combobox" at its literal meaning.
__________________
Always parameterize your queries - read more here
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #7 (permalink)  
Old 07-09-2009, 5:30 AM
VB.NET Forum Enthusiast
.NET Framework: .NET 3.0 (VS 2005/2008)
 
Join Date: May 2008
Location: Spain
Posts: 82
Reputation: 25
J Trahair is on a distinguished programming path ahead
Default

Sorry, I should have explained it better to begin with.

I have a datagrid in VB 2005, where each cell in column 8 is a combobox contain currency symbols eg. £, €, $. When the user enters any cell in this column, they are forced to accept one of the currency symbols, and not to type in something else.

I tried
HTML Code:
            Dim cell As New DataGridViewComboBoxCell
            cell.Items.Add("A")
            cell.Items.Add("B")
            Me.grd1.Item(grd1.CurrentCellAddress.X, grd1.CurrentCellAddress.Y) = cell
in grd1_CellEnter, but the behaviour was quirky and there were error messages. Plainly, that's the wrong place, although the code segment looks promising.

Where should I put the code, for best results? Thank you.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #8 (permalink)  
Old 07-09-2009, 7:02 AM
JohnH's Avatar
VB.NET Forum Moderator
.NET Framework: .NET 3.5 (VS 2008)
 
Join Date: Dec 2005
Location: Norway
Age: 37
Posts: 10,173
Reputation: 1273
JohnH has a reputation beyond reputeJohnH has a reputation beyond reputeJohnH has a reputation beyond reputeJohnH has a reputation beyond reputeJohnH has a reputation beyond reputeJohnH has a reputation beyond reputeJohnH has a reputation beyond reputeJohnH has a reputation beyond reputeJohnH has a reputation beyond reputeJohnH has a reputation beyond reputeJohnH has a reputation beyond repute
Default

As I said, just add a combo column in Designer. You can also add the items there.
__________________
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Reply

Bookmarks


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
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

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





All times are GMT -4. The time now is 1:10 PM.

Powered by vBulletin® Version 3.8.4
Copyright ©2000 - 2010, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.3.2


For advertising opportunities click here.