Notifications
Clear all
[Closed] Change Handlers & dotNet
May 09, 2011 6:21 pm
Hi guys, i was testing a kind of simple “Position Inspector” using a .net dataGridView object and “When transform” change handler. The problem is that position coords displayed on the DGV, updates too slow when moving the box over long distances. Is that normal?, is there a better or faster way to expose transform data on a dataGridView object?.
function testChangeHandler =
(
box name:"testBox" -- test object
select $testBox
-- theForm
theForm = dotNetObject "MaxCustomCOntrols.MaxForm"
theForm.text = "DGV Change Handler Test"
theForm.width = 300
theForm.height = 200
theForm.topMost = true
-- The dataGridView
myDGV = dotNetObject "System.Windows.Forms.DataGridView"
myDGV.location = dotNetObject "System.Drawing.Point" 0 0
myDGV.defaultCellStyle.foreColor = (dotNetClass "System.Drawing.Color").black
myCol1 = dotNetObject "System.Windows.Forms.DataGridViewTextBoxColumn"
myCol1.headerText = "Column 1"
myCol1.width = 100
myCol2 = dotNetObject "System.Windows.Forms.DataGridViewTextBoxColumn"
myCol2.headerText = "Column 2"
myCol2.width = 100
myDGV.columns.add myCol1
myDGV.columns.add myCol2
myDGV.width = 600
myDGV.height = 200
myDGV.rowCount = 3
myDGV.columns.item [0].valueType = dotNetClass "System.Single"
myDGV.rows.item [0].cells.item [0].value ="X Position"
myDGV.rows.item [1].cells.item [0].value ="Y Position"
myDGV.rows.item [2].cells.item [0].value ="Z Position"
theForm.controls.add myDGV
theForm.Show()
theForm
deleteAllChangeHandlers id:#whenTransform
when transform $testBox changes id:#whenTransform do
(
myDGV.rows.item [0].cells.item [1].value =$.position.x
myDGV.rows.item [1].cells.item [1].value =$.position.y
myDGV.rows.item [2].cells.item [1].value =$.position.z
)
) -- testChangeHandler
testChangeHandler ()
3 Replies
May 09, 2011 6:21 pm
datagridview updates as fast as it can. i don’t think this is an issue. try to change when to:
when transform $testBox changes id:#whenTransform handleAt:#redrawViews do (...)
May 09, 2011 6:21 pm
you are also missing a global declaration for myDGV in line 14.
global myDGV = dotNetObject "System.Windows.Forms.DataGridView"
May 09, 2011 6:21 pm
Thanks, yep, i´ve tied that too. I thaught it would be a better way to pass data coords to .Net to handle them faster. Thanks guys!.