Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
placing controls
I am dynamically creating controls on a vba userform. Now I had to face the
fact, that even though I use integers to place these controls using their TOP, LEFT, HEIGHT and WIDTH properties, there is almost always a slight different from the actual view to what I try to draw. This is best seen if there are several controls that have just a small space between them. The userforms then look really improper. Has somebody experience with this issue? Do I have to put my controls into a certain grid to get better results? Thanks for any hints. Luc To reproduce this issue create a userform, put following code into its code panel and show it. The created rectangles SHOULD have a constant spacing of 2 point. ' *** start of code *** Private Sub UserForm_Initialize() With Me.Controls.Add("Forms.Image.1") .Top = 5 .Left = 5 .Height = 50 .Width = 50 End With With Me.Controls.Add("Forms.Image.1") .Top = 7 .Left = 7 .Height = 46 .Width = 46 End With With Me.Controls.Add("Forms.Image.1") .Top = 9 .Left = 9 .Height = 42 .Width = 42 End With With Me.Controls.Add("Forms.Image.1") .Top = 11 .Left = 11 .Height = 38 .Width = 38 End With With Me.Controls.Add("Forms.Image.1") .Top = 13 .Left = 13 .Height = 34 .Width = 34 End With With Me.Controls.Add("Forms.Image.1") .Top = 15 .Left = 15 .Height = 30 .Width = 30 End With End Sub '*** end of code *** |
#2
Posted to microsoft.public.excel.programming
|
|||
|
|||
placing controls
I think I'd just create the userform manually exactly the way I want to see it.
Then hide those controls that need to be "added" later. And make them visible instead of creating them. Luc Benninger wrote: I am dynamically creating controls on a vba userform. Now I had to face the fact, that even though I use integers to place these controls using their TOP, LEFT, HEIGHT and WIDTH properties, there is almost always a slight different from the actual view to what I try to draw. This is best seen if there are several controls that have just a small space between them. The userforms then look really improper. Has somebody experience with this issue? Do I have to put my controls into a certain grid to get better results? Thanks for any hints. Luc To reproduce this issue create a userform, put following code into its code panel and show it. The created rectangles SHOULD have a constant spacing of 2 point. ' *** start of code *** Private Sub UserForm_Initialize() With Me.Controls.Add("Forms.Image.1") .Top = 5 .Left = 5 .Height = 50 .Width = 50 End With With Me.Controls.Add("Forms.Image.1") .Top = 7 .Left = 7 .Height = 46 .Width = 46 End With With Me.Controls.Add("Forms.Image.1") .Top = 9 .Left = 9 .Height = 42 .Width = 42 End With With Me.Controls.Add("Forms.Image.1") .Top = 11 .Left = 11 .Height = 38 .Width = 38 End With With Me.Controls.Add("Forms.Image.1") .Top = 13 .Left = 13 .Height = 34 .Width = 34 End With With Me.Controls.Add("Forms.Image.1") .Top = 15 .Left = 15 .Height = 30 .Width = 30 End With End Sub '*** end of code *** -- Dave Peterson |
#3
Posted to microsoft.public.excel.programming
|
|||
|
|||
placing controls
It must be a rounding issue I suppose. Somewhere behind the scenes Excel has
to round your given values to the nearest available pixel. I don't know of a way to work out when & which way that rounding will go. But FWIW, you'll see better results if you increment by 1.5 points or 3 points instead of 2. Regards, Vic Eldridge "Luc Benninger" <lb (at) zignet.ch wrote in message ... I am dynamically creating controls on a vba userform. Now I had to face the fact, that even though I use integers to place these controls using their TOP, LEFT, HEIGHT and WIDTH properties, there is almost always a slight different from the actual view to what I try to draw. This is best seen if there are several controls that have just a small space between them. The userforms then look really improper. Has somebody experience with this issue? Do I have to put my controls into a certain grid to get better results? Thanks for any hints. Luc To reproduce this issue create a userform, put following code into its code panel and show it. The created rectangles SHOULD have a constant spacing of 2 point. ' *** start of code *** Private Sub UserForm_Initialize() With Me.Controls.Add("Forms.Image.1") .Top = 5 .Left = 5 .Height = 50 .Width = 50 End With With Me.Controls.Add("Forms.Image.1") .Top = 7 .Left = 7 .Height = 46 .Width = 46 End With With Me.Controls.Add("Forms.Image.1") .Top = 9 .Left = 9 .Height = 42 .Width = 42 End With With Me.Controls.Add("Forms.Image.1") .Top = 11 .Left = 11 .Height = 38 .Width = 38 End With With Me.Controls.Add("Forms.Image.1") .Top = 13 .Left = 13 .Height = 34 .Width = 34 End With With Me.Controls.Add("Forms.Image.1") .Top = 15 .Left = 15 .Height = 30 .Width = 30 End With End Sub '*** end of code *** |
#4
Posted to microsoft.public.excel.programming
|
|||
|
|||
placing controls
Great Vic! The values for Width and Height properties of the controls must
be a multiple of 0.75! Thanks, Luc "Vic Eldridge" wrote in message m... It must be a rounding issue I suppose. Somewhere behind the scenes Excel has to round your given values to the nearest available pixel. I don't know of a way to work out when & which way that rounding will go. But FWIW, you'll see better results if you increment by 1.5 points or 3 points instead of 2. Regards, Vic Eldridge "Luc Benninger" <lb (at) zignet.ch wrote in message ... I am dynamically creating controls on a vba userform. Now I had to face the fact, that even though I use integers to place these controls using their TOP, LEFT, HEIGHT and WIDTH properties, there is almost always a slight different from the actual view to what I try to draw. This is best seen if there are several controls that have just a small space between them. The userforms then look really improper. Has somebody experience with this issue? Do I have to put my controls into a certain grid to get better results? Thanks for any hints. Luc To reproduce this issue create a userform, put following code into its code panel and show it. The created rectangles SHOULD have a constant spacing of 2 point. ' *** start of code *** Private Sub UserForm_Initialize() With Me.Controls.Add("Forms.Image.1") .Top = 5 .Left = 5 .Height = 50 .Width = 50 End With With Me.Controls.Add("Forms.Image.1") .Top = 7 .Left = 7 .Height = 46 .Width = 46 End With With Me.Controls.Add("Forms.Image.1") .Top = 9 .Left = 9 .Height = 42 .Width = 42 End With With Me.Controls.Add("Forms.Image.1") .Top = 11 .Left = 11 .Height = 38 .Width = 38 End With With Me.Controls.Add("Forms.Image.1") .Top = 13 .Left = 13 .Height = 34 .Width = 34 End With With Me.Controls.Add("Forms.Image.1") .Top = 15 .Left = 15 .Height = 30 .Width = 30 End With End Sub '*** end of code *** |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
Placing an UDF | Excel Worksheet Functions | |||
placing.. 1st, 2nd, 3rd... | Excel Discussion (Misc queries) | |||
ActiveX Controls vs Form Controls | Excel Discussion (Misc queries) | |||
placing | Excel Worksheet Functions |