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.
artrender.info's picture

now as I undesrand

I should have

dotnetcontrol pn "MaxCustomControls.MaxUserControl" width:48 height:(table.height-24) pos:[2,153]

iside rollout

and somehow to add split containers iteratively

in such a form

defCB cb (newbitmaps.count*30-2) txt: (m as string) check:false -- 30 - the height of a datagrid row, newbitmaps.count -- count of textures inside ID
 
FLP.Controls.Add(cb)

just instead of this - to call splitcontainers

barigazy's picture

...

The MaxUserControl is one of many types of containes ei. Panels which can hold dotNet object inside. It's not important to use this type U can use simple Panel.
I play a bit maybe this can helps

try(destroyDialog testR)catch()
rollout testR "Test" width:400 height:400
(
	dotnetcontrol pn "MaxCustomControls.MaxUserControl" pos:[5,5] width:390 height:378
	fn defColor r g b = ((dotNetClass "System.Drawing.Color").FromArgb r g b)
	local COL1 = (defColor 80 80 80), COL2 = (defColor 150 150 150),COL3 = (defColor 65 125 88),COL4 = (defColor 125 150 80)
	fn defineSplitCont mainPnl clr1 clr2 w: h: dock: spliter:2 orient:#vert ctrlsIn1st:#() ctrlsIn2st:#()=
	(
		sp = dotnetobject "SplitContainer"
		sp.panel1.backColor = clr1
		sp.panel2.backColor = clr2
		sp.splitterWidth = spliter
		case orient of
		(
			(#vert): sp.Orientation = sp.Orientation.Vertical
			(#horiz): sp.Orientation = sp.Orientation.Horizontal
		)
		if dock then sp.dock = sp.dock.fill else
		(
			if w != unsupplied and h != unsupplied do (sp.width = w ; sp.height = h)
			sp.Location = dotNetObject "System.Drawing.Point" (mainPnl.pos.x) (mainPnl.pos.y)
		)
		if ctrlsIn1st.count != 0 do sp.Panel1.controls.AddRange ctrlsIn1st
		if ctrlsIn2st.count != 0 do sp.Panel2.controls.AddRange ctrlsIn2st	
		sp
	)
	on testR open do 
	(
		pn.backcolor = pn.backcolor.black
		pn.BorderStyle = pn.BorderStyle.FixedSingle
		pn.width = 390 ; pn.height = 390 
		splitC2 = defineSplitCont pn COL3 COL4 dock:off spliter:2 orient:#horiz
		splitC1 = defineSplitCont pn COL1 COL2 w:378 h:378 dock:on spliter:2 ctrlsIn1st:#(splitC2)
 
		pn.controls.add splitC1
	)
)
createDialog testR

barigazy

artrender.info's picture

and

dotNetControl FLP "FlowLayoutPanel" width:48 height:(table.height-24) pos:[2,153]

inside rollout

artrender.info's picture

I had this function previously

	fn dotnetcolor r g b = 
	(
		(dotNetClass "System.Drawing.Color").fromARGB r g b
	)
 
	fn defCB  dnCtrl btnheight txt: check: =
	(
		dnCtrl.Appearance = dnCtrl.Appearance.Button
		dnCtrl.flatappearance.bordersize = 0
		dnCtrl.margin = (dotNetObject "system.windows.forms.padding" 1)
		dnCtrl.width = 20 
		dnCtrl.height = btnheight
		dnCtrl.backcolor = (dotnetcolor 84 84 84) 
		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 MtlFLP "FlowLayoutPanel" width:22 height:(table.height-24) pos:[5,153]--column for materials buttons
dotNetControl FLP "FlowLayoutPanel" width:30 height:(table.height-24) pos:[18,153]--column for mat IDs
--...
 if classof s.material == multimaterial then
(...
	cb = dotNetobject "checkbox"
	defCB cb (newbitmaps.count*30-2) txt: (m as string) check:false -- 30 - the height of a datagrid row, newbitmaps.count -- count of textures inside ID
	FLP.Controls.Add(cb)
)
artrender.info's picture
artrender.info's picture

I don't understand how to use it

and how to create left panel, righ panel and how to split horizontally the right panel

artrender.info's picture

Look!

I still think that it's possible!!!

I've found a script with such a function

		function createSplitContainer =
		(
			-- 
			-- splitContainer1
			-- 
			local splitContainer1 = dotNetObject "System.Windows.Forms.SplitContainer"
			splitContainer1.Dock = splitContainer1.Dock.Fill
			splitContainer1.Name = "splitContainer1"
			splitContainer1.Orientation = splitContainer1.Orientation.Horizontal
			splitContainer1.SplitterWidth = 10
			splitContainer1.SplitterDistance = 50
 
			splitContainer1.Panel1.Controls.Add (createResultList())
 
			local statusStrip = createStatusStrip()
			splitContainer1.Panel2.Controls.Add statusStrip
 
			local resultDetails = createResultDetails()
			resultDetails.Top = 0
			resultDetails.Left = 0
			resultDetails.Width = splitContainer1.Panel2.Width
			resultDetails.Height = splitContainer1.Panel2.Height - statusStrip.Height
			splitContainer1.Panel2.Controls.Add resultDetails
 
			return splitContainer1
		),

This means that split containers can be created iteratively in function!

Just help me please to create one panel on the left and one on the right and a "for" cycle to create n splitcontainers inside right panel. After this, every panel should be filled with a button!

barigazy's picture

...

Yup. I aranged a bit your code. Try it to see if works for you.
No need to use return in this case

function createSplitContainer =
(
	-- 
	-- splitContainer1
	-- 
	local statusStrip = createStatusStrip()
	local resultDetails = createResultDetails()
	local splitContainer1 = dotNetObject "SplitContainer"
	splitContainer1.Dock = splitContainer1.Dock.Fill
	splitContainer1.Name = "splitContainer1"
	splitContainer1.Orientation = splitContainer1.Orientation.Horizontal
	splitContainer1.SplitterWidth = 10
	splitContainer1.SplitterDistance = 50
	resultDetails.Top = 0
	resultDetails.Left = 0
	resultDetails.Width = splitContainer1.Panel2.Width
	resultDetails.Height = splitContainer1.Panel2.Height - statusStrip.Height
	splitContainer1.Panel1.Controls.Add (createResultList())
	splitContainer1.Panel2.Controls.AddRange #(statusStrip, resultDetails)
	splitContainer1
)

barigazy

artrender.info's picture

Barigazy

www.go2sleep.com

artrender.info's picture

I need

like in pic from above to have blend for example which could be placed first sometimes and then multisubobject and after this again a certain material(nonmultisub) - I need it to update, that's why I would like to add splitcontainers in function depending on materialtype. How do you think, is it possible, or should I forget about that?

Comment viewing options

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