Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Change height of combobox column in datagridview

Posted on 2014-03-04
5
Medium Priority
?
1,342 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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

On Demand Webinar: Networking for the Cloud Era

Did you know SD-WANs can improve network connectivity? Check out this webinar to learn how an SD-WAN simplified, one-click tool can help you migrate and manage data in the cloud.

Question has a verified solution.

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

It’s quite interesting for me as I worked with Excel using vb.net for some time. Here are some topics which I know want to share with others whom this might help. First of all if you are working with Excel then you need to Download the Following …
The ECB site provides FX rates for major currencies since its inception in 1999 in the form of an XML feed. The files have the following format (reducted for brevity) (CODE) There are three files available HERE (http://www.ecb.europa.eu/stats/exch…
Do you want to know how to make a graph with Microsoft Access? First, create a query with the data for the chart. Then make a blank form and add a chart control. This video also shows how to change what data is displayed on the graph as well as form…
This tutorial will teach you the special effect of super speed similar to the fictional character Wally West aka "The Flash" After Shake : http://www.videocopilot.net/presets/after_shake/ All lightning effects with instructions : http://www.mediaf…
Suggested Courses

721 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