views:

44

answers:

1

I'm writing an windforms application using .NET (actually IronPython, but that's not relevant), and I have a CheckedListBox object in my GUI.

It's working fine, it has about 20 items in a multicolumn layout. But I can't figure out how to give the thing a nice internal margin--I want to insert around 20 or 30 pixels of whitespace around the top, bottom, left, and right edges of the checkboxes.

To be clear, I want the whitespace to appear between the border of the CheckedListBox and the Checkboxes inside it, not outside the whole component.

Hopefully this is an easy answer, and I'm just missing it cause I'm new to programming in windows. If its not possible, I guess that'd be good to know too, so I don't waste anymore time with it.

(If I were doing this in Swing (Java) I would be looking to set the Insets on my component, or maybe build up a compound border with some empty space in it.)

A: 

The native Window control doesn't support a Padding property, you cannot convince it otherwise. Not a real problem. Simply set the BorderStyle to None and put it in a Panel whose AutoScroll property is True. You'll have to set the list box size in the form's Load event because it might be rescaled. Yuck, that looks wrong. Oh well.

Hans Passant
Ah, I was hoping there'd be a property or something that I'd missed.But it's good to know that there's no straightforward way to do this, at least. Thanks!
Xanatos