Notifications
Clear all

[Closed] FlowLayoutPanel control padding?

 PEN

How does one set this. I want to make the spaces between buttons smaller. Setting margins on buttons or padding on the FLP doesn’t appear to do anything at all.

Any one?

14 Replies
2 Replies
(@denist)
Joined: 11 months ago

Posts: 0

i might sounds weird but you can’t change minimum spacing between controls. it’s a known problem of the FLP.

 MZ1
(@mz1)
Joined: 11 months ago

Posts: 0

You can change margins of buttons to (near) zero:

rollout MarginTest “Margin Test” width:478 height:143
(
dotNetControl FLP “flowLayoutPanel” pos:[6,5] width:466 height:100
spinner spn_MarginValue “Margin Value” pos:[80,115] width:60 height:16 range:[-10,100,3]

local buttons

on MarginTest open do
(
FLP.autoscroll = true
Buttons = for i=1 to 10 collect
(
b = dotNetObject “Button”
FLP.controls.add b
b
)

)

on spn_MarginValue changed val do
(
for b in Buttons do b.Margin = dotnetobject “system.windows.forms.padding” Val
)
)
createdialog MarginTest

 PEN

OH that sucks! Ah well, easiest way to do it right now. Live with what I have.

when I wrote Hitchhiker I managed to set a property to control the space between buttons, and it was just setting the control margin when populating. does this not work?

rollout flptest "" width:450 height:146
(
	local UIBind = (dotnetclass "managedservices.cuiupdater").getinstance()
	dotNetControl flp1 "flowlayoutpanel" pos:[4,5] width:160 height:115
	dotNetControl flp2 "flowlayoutpanel" pos:[168,5] width:280 height:138
	
	on flptest open do
	(
		btns = for margin in #(0,6) collect
		(
			for i = 1 to 10 collect 
			(
			bn = dotnetobject "button" 
			bn.width = 80
			bn.backcolor = UIBind.GetControlColor()
			bn.forecolor = UIBind.GetTextColor()
			bn.flatstyle = bn.flatstyle.flat
			bn.text = "Boom" + i as string	
			bn.margin = dotnetobject "padding" margin
			bn
			)
		)
		
		flp1.controls.addrange btns[1]
		flp2.controls.addrange btns[2]
	)
)
createdialog flptest
1 Reply
(@denist)
Joined: 11 months ago

Posts: 0

Ha! it works. I tried

 <control>.Margin.All = 0 

and it didn’t work, but

  <control>.Margin = dotNetObject "Padding" 0

works! Good to know. Thanks!

there is some minimum spacing between cells in the built-in flowlayoutpanel … it’s probably 6 pixels (3 from every edge). there is no way (at least i couldn’t find) to set it less. you can change ‘visual’ spacing to look greater by changing margins off controls in cells, but can’t look it less.
the microsoft’s answer to this question is something like – if you don’t like ours write your own. they kindly provide a sample http://msdn.microsoft.com/en-us/library/system.windows.forms.layout.layoutengine.aspx

 PEN

Hey Pete. Wow, this is exactly what I tried and I didn’t get any change, now it works as it should. That is what you get for coding on a Sunday while getting your ass handed to you by an 8 year old in Risk.

Thanks

 PEN

Might have been that I was trying to set the .top property only. Setting the whole margin works and you have to set all of them if you want to work on just one.

It is off set by one from what HTML is. The order is left, top, right, bottom.


quickSelectBt.margin=dotNetObject "padding" 4 1 0 0

Hey Paul,

You should never code while attempting to beat a child at Risk. It’s in the max help.

Left and top values are how I set the padding in Hitchhiker, just to differentiate. You can also set flatappearance.bordersize to 0 on a flat button which tucks them in even more. below is it set to 0 with a left/top button margin set to 1.

 PEN

Just try top of left, that didn’t work for me. Interesting that All works.

Thanks again Pete.

1 Reply
(@denist)
Joined: 11 months ago

Posts: 0

All, Bottom, Top, Left, and Right… nothing works for me 2010/64-2012/64. I doesn’t work for both Margin and Padding. If I set the “Padding” object creating it by any constructor it works.

 PEN

Interesting, I’m in 2013 currently.

this code works in 2013 and 2010, although I am not on XP, Denis. Padding looks to be a strange one, is it that it needs a new instance of the padding class each time, rather than adjusting the properties of the existing one?

rollout flptest "" width:450 height:146
(
	local b = dotnetclass "button" 
	local pd = dotnetclass "padding"
	local UIBind = (dotnetclass "managedservices.cuiupdater").getinstance()
	dotNetControl flp1 "flowlayoutpanel" pos:[4,5] width:163 height:138
	dotNetControl flp2 "flowlayoutpanel" pos:[170,5] width:280 height:138
	
	on flptest open do
	(
		flp1.backcolor = flp2.backcolor = flp1.backcolor.gray
		btns = for margin in #(1,6) collect
		(
			for i = 1 to 10 collect 
			(
			bn = dotnetobject b
			bn.width = 80
			bn.backcolor = UIBind.GetControlColor()
			bn.forecolor = UIBind.GetTextColor()
			bn.flatstyle = bn.flatstyle.flat
			bn.flatappearance.bordersize = 0
			bn.text = "Boom" + i as string
			bn.margin = dotnetobject pd margin margin 0 0			
			bn
			)
		)
		
		flp1.controls.addrange btns[1]
		flp2.controls.addrange btns[2]
	)
)
createdialog flptest
Page 1 / 2