Notifications
Clear all

[Closed] Interactive spreadsheet (dotNet dataGridView)?

I’m currently doing work with cylinder-based meshes. I have a script set up that allows me to move the individual points around via spinners, but due to the large number of points it quickly becomes unwieldy.

I’m looking to create an interactive spreadsheet similar in use to the skin modifier “skin weight table”. I’m kind of a dotNet newbie, but I’m guessing that the dataGridView form would be a good bet? I was hoping that Bobo’s SSE might give me a good template to work with, but unfortunately it was written back in the ActiveX days.

If someone could confirm for me that dataGridView is the form I want to use, and maybe give me a bare-bones template showing how to set it up, I’m sure I could figure out the rest from there.

10 Replies
1 Reply
(@denist)
Joined: 11 months ago

Posts: 0

try to search in this forum for dataGridView. I (and some our friends from the forum) posted some templates showing how to use and work with data grid not long ago.

Hmm… I found a few threads talking about DataGridView, but I’m still not sure what I’m doing. What I have, that I want to use as an input, is a 2 dimensional array of integers. I want to be able to use each sub-array as a column in the table, i.e.

   I can get the values all lined up using a ListView, but I'm under the impression that I can't put them in spinners that way. I was hoping I would be able to do it with DataGridView, but I don't really understand how to populate the table (or really what I'm doing at all. :shrug: )

EDIT: I just realized that in my illustration I actually used the sub-arrays as my rows rather than my columns. It’s not significant to my problem, and I mention it just to avoid confusion!

probably the using dataGridView in your case is not right idea. Data Grid by default doesn’t have Spinner (NumericUpDown) Edit Cell Control. It’s possible to write it but it’s not trivial.
It’s better to use DevExpress Tree List Control. Here is a template:


 try(form.close()) catch()
 form = dotnetobject "MaxCustomControls.Maxform"
 form.size = dotnetobject "System.Drawing.Size" 400 200
 
 	   lv = dotnetobject "DevExpress.xtraTreeList.treeList"
 	lv.dock = lv.dock.fill
 	
 	subarray = #(#(17,2,3,6),#(16,4,5,7),#(15,8,9,11),#(14,12,13,18))
 		
 	   fn initLV lv =
 	   (		
 		lv.OptionsSelection.MultiSelect = on
 		   lv.OptionsView.ShowRoot = lv.OptionsView.ShowIndicator = off
 		   lv.OptionsView.AutoWidth = on
 		   
 		   col = lv.columns.add()
 		   col.visible = on
 		   col.width = 120
 		   col.caption = "Sub-Array ID"
 		col.OptionsColumn.AllowEdit = off
 		col.fixed = col.fixed.left
 		   
 		   sp = dotNetObject "DevExpress.XtraEditors.Repository.RepositoryItemSpinEdit"
		 sp.isFloatValue = off
 		sp.Appearance.TextOptions.HAlignment = sp.Appearance.TextOptions.HAlignment.Near
 		   lv.RepositoryItems.add sp
 		
 		for k=1 to 4 do
 		(
 			col = lv.columns.add()
 			col.visible = on
 			col.caption = "Index " + (k as string)
 			col.columnEdit = sp
 			col.AppearanceCell.TextOptions.HAlignment = sp.Appearance.TextOptions.HAlignment
 		)
 		for s=1 to subarray.count do lv.appendNode (#(s as string) + subarray[s]) -1
 	   )
 	
 initLV lv
 form.controls.add lv  
 form.showmodeless()
 

you can find more samples in this forum…

hm… tried that but got some errors:

undefined
-- Runtime error: Cannot resolve type: MaxCustomControls.Maxform
-- Unknown property: "size" in undefined
-- Runtime error: Cannot resolve type: DevExpress.xtraTreeList.treeList
-- Unknown property: "dock" in undefined
#(#(17, 2, 3, 6), #(16, 4, 5, 7), #(15, 8, 9, 11), #(14, 12, 13, 18))
initLV()
-- Error occurred in initLV()
--  Frame:
--   sp: undefined
--   col: undefined
--   lv: undefined
-- Unknown property: "OptionsSelection" in undefined
-- Unknown property: "controls" in undefined
-- Unknown property: "showmodeless" in undefined
OK
1 Reply
(@denist)
Joined: 11 months ago

Posts: 0

what version of max are you using?

change “MaxCustomControls.Maxform” to “Form”
and
.showmodeless() to .show()

Since the lines including the DevExpress definitions were not working, I tried looking up DevExpress. Unless I am mistaken, that appears to be a set of commercial third party controls, and not a built in component of dotNet?

Also, I’m using Max 9. I’m not sure if the plugin I’m using will work with later versions of Max (I have just sent an email inquiring about that and not gotten a response yet.) However, assuming that I am stuck using Max 9, is there anything I can do?

If I can get the plugin working with Max 2009, I think I may look into using XPTable, which I have just discovered here: http://tech-artists.org/wiki/XPTable_(.NET)

1 Reply
(@denist)
Joined: 11 months ago

Posts: 0

DevExpress controls are coming with MAX 2009 and higher. So, it’s free to use.

I don’t support versions of max lower then MAX 2009 and don’t care about them. Sorry.

Denis, I’m getting this error too, and I ‘m running max 2010.

-- Runtime error: Cannot resolve type: DevExpress.xtraTreeList.treeList

1 Reply
(@light)
Joined: 11 months ago

Posts: 0
 It happens because the forum probably screwed the formatting of the fully qualified name of this object:
sp = dotNetObject "DevExpress.XtraEditors.Repository.RepositoryItemSp  inEdit
 which should be [this]( http://utilitybase.com/paste/27459).  (Can't paste it here without the forum putting a space into the name.)

 

 
 Light

Well anyway, I’m still waiting back to hear whether the plugin I’m using can work with Max 2009. In the meantime, I’ve managed to get XPTable working as far as the tutorial shown here: http://tech-artists.org/wiki/XPTable_(.NET)

In my case, the code is as follows*
(*The commented code at the top should be run the first time in order to load the array values into memory)

/*
mArray = #("m1","m2","m3","m4")

connectArray =
#(
	#(
		#(undefined, 20), #(4, 20), #(15, 5), #(24, undefined)),
		#(#(undefined, 20), #(5, 19), #(15, 4), #(24, undefined)),
		#(#(undefined, 20), #(5, 19), #(15, 3), #(25, undefined)),
		#(#(undefined, 20), #(5, 19), #(15, 3), #(26, undefined)),
		#(#(undefined, 20), #(5, 19), #(15, 2), #(27, undefined)),
		#(#(undefined, 20), #(5, 19), #(15, 2), #(27, undefined)),
		#(#(undefined, 20), #(6, 19), #(15, 2), #(27, undefined)),
		#(#(undefined, 20), #(6, 19), #(15, 2), #(27, undefined)),
		#(#(undefined, 24), #(6, 19), #(15, 2), #(27, undefined)),
		#(#(undefined, 24), #(6, 20), #(15, 2), #(27, undefined)),
		#(#(undefined, 24), #(6, 20), #(15, 2), #(27, undefined)),
		#(#(undefined, 24), #(6, 20), #(15, 20), #(27, undefined)),
		#(#(undefined, 24), #(6, 20), #(15, 20), #(27, undefined)),
		#(#(undefined, 24), #(6, 20), #(15, 19), #(27, undefined)),
		#(#(undefined, 24), #(6, 20), #(15, 19), #(27, undefined)),
		#(#(undefined, 24), #(6, 20), #(6, 19), #(27, undefined)),
		#(#(undefined, 25), #(6, 20), #(6, 19), #(7, undefined)),
		#(#(undefined, 25), #(12, 21), #(6, 19), #(7, undefined)),
		#(#(undefined, 26), #(12, 26), #(6, 19), #(7, undefined)),
		#(#(undefined, 1), #(12, 26), #(6, 19), #(7, undefined)
	)
)
*/


global RO_XPTable
try (destroyDialog RO_XPTable) catch()



dotNet.loadAssembly "XPTable.dll"
dotNet.loadAssembly "MaxCustomControls.dll"

table1 = dotNetObject "XPTable.Models.Table"
columnModel1 = dotNetObject "XPTable.Models.ColumnModel"
tableModel1 = dotNetObject "XPTable.Models.TableModel"

table1.ColumnModel = columnModel1
table1.TableModel = tableModel1

table1.GridColor = table1.gridColor.Silver
table1.GridLines = table1.gridLines.Both

columnModels = #("Text"); for m = 1 to (mArray.count - 1) do (append columnModels "Number"; append columnModels "Number")
xpTableModelText = ("dotNetObject \"XPTable.Models.")
columnWidth = #(100); for m = 1 to (mArray.count - 1) do (append columnWidth 50; append columnwidth 50)

columnArray = #();
for i = 1 to columnModels.count do 
(
	columnArray[i] = execute (xpTableModelText + columnModels[i] + "Column\" \"" + columnModels[i] + "\" ")
	columnArray[i].Width = columnWidth[i];
	columnModel1.Columns.Add columnArray[i]
)

rowCount = connectArray.count
rowArray = #()
cellArray = #()


	
for i = 1 to rowCount do
(
	rowArray[i] = execute (xpTableModelText + "Row\"")
	tableModel1.Rows.Add rowArray[i]

	append cellArray #();

	for j = 1 to columnArray.count do
	(
		cellArray[i][j] = execute (xpTableModelText + "Cell\" \" \"")
		cellArray[i][j].BackColor = bkColor
	)		
	rowArray[i].Cells.AddRange cellArray[i]
	
	cellArray[i][1].Text = ("Section: " + i as string)
	cellArray[i][1].editable = false	
)	



uint64_min = dotNetObject "System.UInt64" 0
dec_min = dotNetObject "System.Decimal" uint64_min

uint64_max = dotNetObject "System.UInt64" 1000
dec_max = dotNetObject "System.Decimal" uint64_max
	
for c = 2 to columnArray.count do
(
	columnArray[c].ShowUpDownButtons = true
	columnArray[c].Minimum = dec_min
	columnArray[c].Maximum = dec_max
)
	
for m = 1 to (mArray.count - 1) do
(
	for x = 1 to rowCount do (cellArray[x][(m*2)].Data = connectArray[x][m][2])
)

for m = 2 to mArray.count do
(
	for x = 1 to rowCount do (cellArray[x][(m*2)-1].Data = connectArray[x][m][1])
)
	
	
	
table1.height = 325
table1.width = 0; for c in columnWidth do table1.width += (c + 6)



rollout RO_XPTable "XP Table"
(
	dotNetControl XPTableControl "System.Windows.Forms.ListView" width:(table1.width) height:325
	on RO_XPTable open do (XPTableControl.controls.add table1)
)
createDialog RO_XPTable width:(table1.width + 20)

Unfortunately, my dotNet skills are weak, and the tutorial looks like it cuts off before showing how to make the XPTable interact with the scene. I need to be able to update the connectArray values based on the corresponding cells in the table. Any advice on this?