[Closed] DataGridViewNumericUpDown inside MaxForm Problem
Hi all!
I have a DataGridView with DataGridViewNumericUpDown cells from msdn sample:
http://msdn.microsoft.com/en-us/library/aa730881%28v=vs.80%29.aspx
when i use them in a DataGridView control inside a maxscript dialog they work fine,
but when i use them inside a Maxform, the DataGridView works fine the first time i execute the script, and the next times the DataGridView can not redraw correctly.
The dll used ” DataGridViewNumericUpDownElements.dll” is just the code from the msdn sample compiled.
This basic code works fine:
(
dotNet.loadAssembly (@"C:\DataGridViewNumericUpDownElements.dll")
global dataGridViewRol
try (destroydialog dataGridViewRol)
catch()
rollout dataGridViewRol "DataGridView"
(
dotnetcontrol dgv "DataGridView" width:250 height:150 align:#center
on dataGridViewRol open do
(
dgv.Dock = dgv.Dock.Fill
textColumn = dotnetobject "DataGridViewTextBoxColumn"
textColumn.AutoSizeMode = (dotNetClass "System.Windows.Forms.DataGridViewAutoSizeColumnMode").Fill
dgv.columns.add textColumn
--DataGridViewNumericUpDownColumn
nupColumn = dotnetobject "DataGridViewNumericUpDownElements.DataGridViewNumericUpDownColumn"
nupColumn.headerText = "NumericUpDownColumn"
nupColumn.DecimalPlaces = 0
nupColumn.Maximum = 100
nupColumn.Minimum = 1
nupColumn.AutoSizeMode = (dotNetClass "System.Windows.Forms.DataGridViewAutoSizeColumnMode").Fill
dgv.columns.add nupColumn
for i = 1 to 5 do
(
row = dotnetobject "DataGridViewRow"
row.DefaultCellStyle = dgv.RowsDefaultCellStyle
dgv.rows.add row
row.cells.item[0].value = "Number " + ((dgv.rows.Count - 1) as string)
row.cells.item[1].value = dgv.rows.Count - 1
)
)
)
createdialog dataGridViewRol 300 200 style:#(#style_titlebar,#style_resizing,#style_sysmenu)
)
but thiscode breaks all the DataGridViews that use DataGridViewNumericUpDown, not only inside a MaxForm:
(
dotNet.loadAssembly (@"C:\DataGridViewNumericUpDownElements.dll")
global form
try(form.Close())catch()
form = dotNetObject "MaxCustomControls.MaxForm"
dgv = dotNetObject "DataGridView"
dgv.Dock = dgv.Dock.Fill
form.Controls.add dgv
textColumn = dotnetobject "DataGridViewTextBoxColumn"
textColumn.AutoSizeMode = (dotNetClass "System.Windows.Forms.DataGridViewAutoSizeColumnMode").Fill
dgv.columns.add textColumn
--DataGridViewNumericUpDownColumn
nupColumn = dotnetobject "DataGridViewNumericUpDownElements.DataGridViewNumericUpDownColumn"
nupColumn.headerText = "NumericUpDownColumn"
nupColumn.DecimalPlaces = 0
nupColumn.Maximum = 100
nupColumn.Minimum = 1
nupColumn.AutoSizeMode = (dotNetClass "System.Windows.Forms.DataGridViewAutoSizeColumnMode").Fill
dgv.columns.add nupColumn
for i = 1 to 5 do
(
row = dotnetobject "DataGridViewRow"
row.DefaultCellStyle = dgv.RowsDefaultCellStyle
dgv.rows.add row
row.cells.item[0].value = "Number " + ((dgv.rows.Count - 1) as string)
row.cells.item[1].value = dgv.rows.Count - 1
)
form.showmodeless()
)
Looks like a stupid error but i have not been found a solution. I can use a maxscript rollout or dialog, but i prefer a MaxForm if it is possible.
Thanks in advance!