I try to fill a DotNet DataGridView via MultiThreading. It makes Max crash (Max gets totally unresponsive and i have to kill it via task manager). Any help would be awesome!
If i add more rows (via multithreading) than "fit" (so that a scrollbar has to be created), 3Ds Max crashes. It works if you just execute "addItems()" without any Multithreading.
Try the snipped below. As soon as you comment out
the 3rd "dgv.rows.add()" it works (because no scrollbar has to be created?!).
Might be possible to modify the DataSource of the DatagridView directly via DotNet DataTable but it seems that this doesn't work (except you use a dotNet form instead of a Maxscript Rollout). The DataGridView doesn't show any data/stays gray) - found one thread where a guy tried the same, without success.
1. Any idea how i can modify (add/remove) the DataGridView without crashing max?
2. Any idea how i can bind a dataTable to the DataGridView in a MaxscriptRollout?
rollout dgTest "DataGridView Test" width:448 height:600
dotNetControl dgv "System.Windows.Forms.DataGridView" pos:[8,8] width:432 height:110
fn addItems = (
--Comment this out to avoid a Max crash
on dgTest open do (
--Create a Column and add it to the DataGridView
infoCol = dotNetObject "System.Windows.Forms.DataGridViewTextBoxColumn"
infoCol.headerText = "Info"
--Execute the addItems Function via MultiThreading
myThread = dotnetobject "CSharpUtilities.SynchronizingBackgroundWorker"
dotnet.addEventHandler myThread "DoWork" addItems