473,503 Members | 2,046 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

ComboBox display value width

Hi
Is there a way to have the view/display width different from the width as it
sits on the form?

Thanks
Brian
Jul 7 '06 #1
3 3940
You can set the width of the ComboBox at runtime like so where XXX is
an integer representing the number of pixels:

ComboBox.Width = XXX;

BrianDH wrote:
Hi
Is there a way to have the view/display width different from the width as it
sits on the form?

Thanks
Brian
Jul 7 '06 #2
OK, its not the combo width, the width of the dropdown text value field when
someone clicks the combobox. so the combo is width 50 but there are values
that are 100 long, so when the user clicks the combo the drop down part is
wider than the combo control.

Brian

"travisj" wrote:
You can set the width of the ComboBox at runtime like so where XXX is
an integer representing the number of pixels:

ComboBox.Width = XXX;

BrianDH wrote:
Hi
Is there a way to have the view/display width different from the width as it
sits on the form?

Thanks
Brian

Jul 7 '06 #3
Change Dropdown Width
int maxWidth = 100;
using (Graphics g = ComboBox.CreateGraphics())
{
foreach (object o in ComboBox.Items)
{
int w = Convert.ToInt32(g.MeasureString(o.ToString(), ComboBox.Font).Width);
if (w maxWidth) maxWidth = w;
}
}
ComboBox.DropDownWidth = maxWidth;

"BrianDH" wrote:
Hi
Is there a way to have the view/display width different from the width as it
sits on the form?

Thanks
Brian
Jul 7 '06 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
14508
by: Oliver Hoehle | last post by:
Hello! This ist the source-code for an editable combobox implemented with HTML,CSS and Javascript. I have tested it with IE and Mozilla. But I don't know, if it will work in other browsers...
3
3016
by: PeterZ | last post by:
G'day, After doing much searching and pinching bits of ideas from here there and everywhere I came up with a fairly 'clean' solution of including a comboBox into a dataGrid column. You can...
2
4315
by: pei_world | last post by:
I want to implement a key hit with enter to dropdown a combobox that is in the datagrid. in this case I need to override its original behaviours. I found some codes from the web. Does anyone know...
2
6168
by: Don | last post by:
I've looked high and low for some code that will allow me to have a combobox with a flat borderstyle. I found a few examples, but nothing that was really usable for me. I had the following...
2
12495
by: AMDRIT | last post by:
Hello Everyone, I would like to format the Display Members of a combobox's datasource. Is there a way to apply a format without subclassing the original datasource? For example, given a list of...
3
2218
by: BrianDH | last post by:
Hi Is there a way to have the view/display width different from the width as it sits on the form?
14
6532
by: Mark | last post by:
I have a table with a field that uses a combobox to populate values. The Lookup tab within table design mode is the following: Display Control Combo Box Row Source Type ...
3
4786
by: =?Utf-8?B?V29ua28gdGhlIFNhbmU=?= | last post by:
Hello, I have a ComboBox with a style that sets its Template and ItemTemplate. I'd like to set the tooltip of the combo to the tooltip of the currently selected item, but I am having trouble...
1
3522
by: Man4ish | last post by:
Hi, How Eventlistner can be used with rendred combo box. I got one example of combobox in table as follows . /* * Copyright (c) 1995 - 2008 Sun Microsystems, Inc. All rights reserved. * ...
0
7204
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
7282
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
7464
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
5586
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
4680
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
3171
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
3162
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
1516
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
1
741
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.