Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Change height of combobox column in datagridview

Posted on 2014-03-04
5
Medium Priority
?
1,403 Views
Last Modified: 2014-03-06
I can change the height of a normal combobox

I can change the row height of a row in a datagridview

But how do i change the height of a combobox column which is in a datagridview?
0
Comment
Question by:SweetingA
  • 3
  • 2
5 Comments
 
LVL 40
ID: 39905734
By height, I suppose that you are meaning the number of lines to display, because the Height if fixed in the standard ComboBox.

You can change the number of elements in a DataGridViewComboBoxColumn by setting the column's MaxDropDownItems property.
0
 

Author Comment

by:SweetingA
ID: 39907743
No i mean the height (thickness)

I have changed the row height of the datagrid but the combo box thickness is now less than half the row thickness

I can't click on the combobox to change its properties because i added it in code so its not visible to click on, therefore i need to change its size in code

Dim cbo As New DataGridViewComboBoxColumn()
DataGridView1.Columns.Add(cbo)

Thanks
0
 
LVL 40

Accepted Solution

by:
Jacques Bourgeois (James Burger) earned 1500 total points
ID: 39907826
Even if you could click on the ComboBox, you would not be able to change it's height, because there is no Height or Size property on a DataGridViewComboBoxColumn. You can change the height of the Row, but the ComboBox has a predefined and fixed height, just as a CheckBox has a fixed size.

The only way to change it is by changing the Font, but since the only place where you can change the Font is at the grid level, that would not make any sense.

As far as I know, this is also the only way to change the Height on a normal ComboBox.

And it makes sense. Since a ComboBox cannot display multiple lines for a given item, changing its height without changing the Font will leave you with a useless blank in the ComboBox.

I understand that you might want to change the height in a grid if you changed the row height, but Microsoft did not seem to think it was useful to change the height of the ComboBox even in that situation.

If you really want to do it, I think that you will be stuck with one for the 2 following solutions.

Inherits from the DataGridViewComboBoxColumn class and create your own class, where you override the Paint event and draw the thing yourself. Good luck with that one.

Create the column as a TextBoxColumn. When the user enter a cell in your column, temporarily display a standard ComboBox over it, and set its selection to the content of the cell. When the user gets out of the ComboBox, copy the new selection in the Cell and make the ComboBox invisible until it is needed again.
0
 

Author Comment

by:SweetingA
ID: 39908906
ok james, thanks for the info

I do understand why its not available, i was just attempting to keep things looking pretty

Actually it doesn't look that bad.
0
 

Author Closing Comment

by:SweetingA
ID: 39908908
although it never provided a solution, the problem very well explained
0

Featured Post

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

If you're writing a .NET application to connect to an Access .mdb database and use pre-existing queries that require parameters, you've come to the right place! Let's say the pre-existing query(qryCust) in Access takes a Date as a parameter and l…
Introduction As chip makers focus on adding processor cores over increasing clock speed, developers need to utilize the features of modern CPUs.  One of the ways we can do this is by implementing parallel algorithms in our software.   One recent…
Is your data getting by on basic protection measures? In today’s climate of debilitating malware and ransomware—like WannaCry—that may not be enough. You need to establish more than basics, like a recovery plan that protects both data and endpoints.…
Look below the covers at a subform control , and the form that is inside it. Explore properties and see how easy it is to aggregate, get statistics, and synchronize results for your data. A Microsoft Access subform is used to show relevant calcul…
Suggested Courses

877 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question