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
|
|
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.
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
"When people discover the center of the universe, a lot of them will be disappointed to find they are not it."
Just add a Combobox column to the DataGridView when you configure its columns.
Some useful links: Learning videoes, Code Samples, WMI Code Creator, MSDN, The Code Project, WindowsClient.net, ASP.net, W3 Schools, Regular-Expressions.info, GDI+ FAQ
How to format posts with code blocks etc - present the problem/post properly
Can we clarify - is this question about a single cell, or a whole column?
Always parameterize your queries- read more here
"When people discover the center of the universe, a lot of them will be disappointed to find they are not it."
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.
Sorry, my mistake then - I took "giving a cell a drop down combobox" at its literal meaning.
Always parameterize your queries- read more here
"When people discover the center of the universe, a lot of them will be disappointed to find they are not it."
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
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.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
Where should I put the code, for best results? Thank you.
As I said, just add a combo column in Designer. You can also add the items there.
Some useful links: Learning videoes, Code Samples, WMI Code Creator, MSDN, The Code Project, WindowsClient.net, ASP.net, W3 Schools, Regular-Expressions.info, GDI+ FAQ
How to format posts with code blocks etc - present the problem/post properly
There are currently 1 users browsing this thread. (0 members and 1 guests)
Bookmarks