create dotnetcontrol buttons inside function

I want to create buttons depending on certain things!
So here is what I need:

fn myfunction=
(
...
 
for i=1 to IDcount do
(
     dotnetcontrol ID_btn[i] "System.Windows.Forms.Button" width:20 height:60 pos:[27,i*153]
     ID_btn[i].backcolor  = (dotnetcolor 70 70 70)
     ID_btn[i].flatstyle = dotnetobject "System.Windows.Forms.FlatStyle" Flat
     ID_btn[i].text="1"
     ID_btn[i].foreColor = (dotnetcolor 200 200 200)
)
)

How to make it work?

Comments

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
barigazy's picture

...

if for btn not work then try with Label control

bga

artrender.info's picture

Text orientation

how to make vertical text orientation for text inside buttons?

dnCtrl.Orientation = (dotNetClass "System.Windows.Forms.Orientation").Vertical

??

barigazy's picture

??? :)

I never try this, but also I think that buttons or checkbuttons not have that property. Find another solution for for your controls placement. Not try to experiment too much, because your GUI creation process may take several months.
Trust me :)

bga

artrender.info's picture

srry, I've found! SOLVED

I had to use

dnCtrl.margin = (dotNetObject "system.windows.forms.padding" 0)
artrender.info's picture

still the same

dnCtrl.margin = dotnetobject (dotnetclass "padding") margin margin 0 0 --gives error

But I've used

dnCtrl.padding = (dotNetObject "system.windows.forms.padding" 0)

but buttons still appear the same way, at a distance of 6px!

artrender.info's picture

Oh, barigazy!

You're awesome!

artrender.info's picture

but how to remove padding around buton?

	fn dotnetcolor r g b = 
	(
		(dotNetClass "System.Drawing.Color").fromARGB r g b
	)
 
	fn defCB dnCtrl txt: check: =
	(
		dnCtrl.Appearance = dnCtrl.Appearance.Button
		dnCtrl.width = dnCtrl.height = 25 ; 
		dnCtrl.backcolor = (dotnetcolor 70 70 70) 
		dnCtrl.forecolor = (dotnetcolor 200 200 200)
		dnCtrl.Cursor = (dotNetClass "Cursors").Hand
		dnCtrl.FlatStyle = dnCtrl.FlatStyle.Flat
		dnCtrl.TextAlign = dnCtrl.TextAlign.MiddleCenter
		dnCtrl.text = txt ; dnCtrl.checked = check
	)
--...
dotNetControl FLP "FlowLayoutPanel" width:30 height:(table.height-24) pos:[18,153]
--...
 
	cb = dotNetobject "checkbox"
	defCB cb txt: "1" check:false
	FLP.Controls.Add(cb)
AttachmentSize
padding_btn.jpg 2.58 KB
barigazy's picture

...

adjust FLP width 2px wider then buttons width

--put theses two lines inside defCB function
dnCtrl.flatappearance.bordersize = 0
dnCtrl.margin = dotnetobject (dotnetclass "padding") margin margin 0 0

bga

artrender.info's picture

Thx Barigazy!

You're a really GREAT PERSON! I will take a look!

barigazy's picture

more infos

You know it's very smart choise to use funcions for .NET objects definition because
your code will have over 1000 lines in most cases only for UI. In free time read this thread to learn .net from masters http://forums.cgsociety.org/showthread.php?f=98&t=551473

bga

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.