Control Width setting Reg

I am loading the controls to the form based on the fields available in the table(Label and combo Control)
how can i set the width of combo control based on the length of the fields described in table.
Pls Help Me
[230 byte] By [Rajalakshmi] at [2007-11-19 11:10:16]
# 1 Re: Control Width setting Reg
You can set the font for the form (or a textbox or picturebox) to the font used for the combobox, then use TextWidth() to find the width of text.
WizBang at 2007-11-9 20:35:32 >
# 2 Re: Control Width setting Reg
I am not able to get u
Rajalakshmi at 2007-11-9 20:36:32 >
# 3 Re: Control Width setting Reg
Examples of the TextWidth function:

http://www.dev-archive.com/forum/showthread.php?t=256425&highlight=textwidth

http://www.dev-archive.com/forum/showthread.php?t=204412&highlight=textwidth

http://www.dev-archive.com/forum/showthread.php?t=27772&highlight=textwidth

http://msdn.microsoft.com/library/default.asp?url=/library/en-us/vb98/html/vbmthTextWidth.asp

http://www.planetsourcecode.com/vb/scripts/ShowCode.asp?txtCodeId=42950&lngWId=1

Have a look there, and hopefully it helps!
HanneSThEGreaT at 2007-11-9 20:37:36 >
# 4 Re: Control Width setting Reg
i am creating the Form(Product Master)
To which the controls like label
and combo box will be added dynamically
based on the fields created in one master table.
for eg the table may contain fields like

Column datatype size
MixCode varchar 50
Ply varchar 20
ValueAddition varchar 100

i will fetch these names and add label and combo box (using control array )

i am able to add the controls--there is no issue in that

Now i want to make each combo of diff size based on its Fields size

Now all the controls seems to appear in same width .

I want to change each combo control of different width based on the datatype size

i can fetch the datasize but i dont know how to assign the width to combo bcoz the width of control ,it will be in pixels in VB form.

i can get the size of mixcode as varchar(50).if assign as such then the control's width becomes very tiny.

pls help me
Rajalakshmi at 2007-11-9 20:38:42 >
# 5 Re: Control Width setting Reg
There are a few possibilities. One way might be if you used a fixed-width font, then you would know the width of each character, so you just multiply the width by the field size. A method which would work for variable-width fonts would be to use Me.TextWidth(String$(FieldSize, 87)). That uses a "W" character, since it will likely be the widest. For numeric data, you could use 48 ("0" character). The border of the control probably needs to be added in to the equation, so you could add a few pixels to account for it.
WizBang at 2007-11-9 20:39:41 >