|
|
|
Tell us what you think of the site.
|
Autodesk Media & Entertainment User Community
|
Autodesk® 3ds Max®
|
|
Autodesk® Maya®
|
|
Autodesk® Softimage®
|
|
Autodesk® MotionBuilder®
|
|
Autodesk® Mudbox™
|
|
Autodesk® ImageModeler™
|
|
Autodesk® Sketchbook® Pro
|
|
Autodesk® Smoke on Mac®
|
| DotNet Checkboxes in ListView
|
|
|
Hello,
how do I add checkboxes to a listview? If found several docs in the web for dotnet generally, but my script doesn’t work. Can anybody help me and give me a hint?
Thank You!
Regards,
Chris
global roDotNetTestDialog global iEntryIndex = 0
fn fnInitDotNetView dncFileView = (
dncFileView.gridLines = true
dncFileView.fullRowSelect = true
dncFileView.MultiSelect = false
dncFileView.View = (dotNetClass "System.Windows.Forms.View").Details
dncFileView.ShowItemToolTips = true
dncFileView.HideSelection = false
dnNewColumn = dncFileView.Columns.add ("Column 1") 150
dnNewColumn = dncFileView.Columns.add ("Column 2") 80
dnNewColumn = dncFileView.Columns.add ("Column 3") 150
dncFileView.refresh()
)
fn fnAddRow dncFileView sInputText = (
iEntryIndex += 1
dnaFileViewItems = #()
dnListItem = dotNetObject "System.Windows.Forms.ListViewItem" ("Entry " + iEntryIndex as string)
dnCheckBox = dotNetObject "System.Windows.Forms.CheckBox"
dnCheckBox.checked = true
dnListItem.SubItems.add dnCheckBox
dnListSubItem = dnListItem.SubItems.add sInputText
append dnaFileViewItems dnListItem
dncFileView.Items.AddRange dnaFileViewItems
)
try(destroyDialog roDotNetTestDialog)catch()
rollout roDotNetTestDialog "DotNet Test Dialog" (
dotNetControl dncFileView "System.Windows.Forms.ListView" pos:[10,10] width:380 height:180
edittext etInputText "Input" pos:[10,200] width:380
button btnAddText "Add" pos:[175,225] width:50 align:#center
on roDotNetTestDialog open do
(
fnInitDotNetView roDotNetTestDialog.dncFileView
)
on btnAddText pressed do
(
fnAddRow roDotNetTestDialog.dncFileView roDotNetTestDialog.etInputText.text
)
)
createDialog roDotNetTestDialog 400 260
|
|
|
|
Add the line of code below to your fnInitDotNetView function and checkboxes will appear to the left of any items added to your list.
dncFileView.CheckBoxes = true
andy.
Max 9.0 through 2010, XP-Pro 64 SP2.
ATI Radeon HD 4800 series
Core 2 Quad Q9650 3.0GHz, 8Gb Ram, DX9.0c.
|
|
|
|
Thanks for your comment!
When I add this line of code nothing changes. I still get the following error, when I add a item to the Viewlist!?
>> MAXScript Rollout Handler Exception: -- Runtime error: No method found which matched argument list <<
|
|
|
|
That is caused by you trying to add checkboxes in fnAddRow. Remove or comment out these lines:
dnCheckBox = dotNetObject "System.Windows.Forms.CheckBox" dnCheckBox.checked = true
dnListItem.SubItems.add dnCheckBox
-Eric
Eric Craft
“The Evil Monkey hiding in your closet.”
|
|
|
|
Try this:)
global roDotNetTestDialog
global iEntryIndex = 0
fn fnInitDotNetView dncFileView = (
dncFileView.gridLines = true
dncFileView.fullRowSelect = true
dncFileView.MultiSelect = false
dncFileView.View = (dotNetClass "System.Windows.Forms.View").Details
dncFileView.ShowItemToolTips = true
dncFileView.HideSelection = false
dncFileView.CheckBoxes = true
dnNewColumn = dncFileView.Columns.add ("Column 1") 150
dnNewColumn = dncFileView.Columns.add ("Column 2") 80
dnNewColumn = dncFileView.Columns.add ("Column 3") 150
dncFileView.refresh()
)
fn fnAddRow dncFileView sInputText = (
iEntryIndex += 1
dnaFileViewItems = #()
dnListItem = dotNetObject "System.Windows.Forms.ListViewItem" ("Entry " + iEntryIndex as string)
dnListSubItem = dnListItem.SubItems.add sInputText
--This is how you can set the checkbox once the item has been created
dnListItem.checked = true
append dnaFileViewItems dnListItem
dncFileView.Items.AddRange dnaFileViewItems
)
try(destroyDialog roDotNetTestDialog)catch()
rollout roDotNetTestDialog "DotNet Test Dialog" (
dotNetControl dncFileView "System.Windows.Forms.ListView" pos:[10,10] width:380 height:180
edittext etInputText "Input" pos:[10,200] width:380
button btnAddText "Add" pos:[175,225] width:50 align:#center
on roDotNetTestDialog open do
(
fnInitDotNetView roDotNetTestDialog.dncFileView
)
on btnAddText pressed do
(
fnAddRow roDotNetTestDialog.dncFileView roDotNetTestDialog.etInputText.text
)
)
createDialog roDotNetTestDialog 400 260
Max 9.0 through 2010, XP-Pro 64 SP2.
ATI Radeon HD 4800 series
Core 2 Quad Q9650 3.0GHz, 8Gb Ram, DX9.0c.
|
|
|
|
Thanks for your help! Now I have a checkbox at the beginning of every line. But it isn’t what I want. I did a little bit retouching. Is it possible realize a dialog in this way?
DotNet Test Dialog - Retouche
|
|
|
|
Checkbox can only be added to the first column of the ListView. You can use DataGridView instead to have checkbox as shown in the pic. I have quickly added a datagridview to your rollout instead of listview. Hope it helps you.
(
local iEntryIndex = 0
txtclmn = dotNetObject "System.Windows.Forms.DataGridViewTextBoxColumn"
cbclmn = dotNetObject "System.Windows.Forms.DataGridViewCheckBoxColumn"
fn fnInitDotNetView dncFileView = (
dncFileView.AllowUserToAddRows = off
dncFileView.AutoSize = on
dncFileView.AutoSizeColumnsMode = dncFileView.AutoSizeColumnsMode.Fill
dncFileView.ColumnHeadersDefaultCellStyle.Alignment = dncFileView.ColumnHeadersDefaultCellStyle.Alignment.MiddleCenter
dncFileView.ShowEditingIcon = dncFileView.RowHeadersVisible = off
txt1 = txtclmn.clone()
txt1.HeaderText = "Object Name"
dncFileView.columns.add (txt1)
cb1 =cbclmn.clone()
cb1.HeaderText = "H"
dncFileView.columns.add (cb1)
cb2 =cbclmn.clone()
cb2.HeaderText = "R"
dncFileView.columns.add (cb2)
txt2 = txtclmn.clone()
txt2.HeaderText = "Notes"
dncFileView.columns.add (txt2)
dncFileView.RowCount = 2
)
try(destroyDialog roDotNetTestDialog)catch()
rollout roDotNetTestDialog "DotNet Test Dialog" (
dotNetControl dncFileView "DataGridView" pos:[10,10] width:380 height:180
edittext etInputText "Input" pos:[10,200] width:380
button btnAddText "Add" pos:[175,225] width:50 align:#center
on roDotNetTestDialog open do
(
fnInitDotNetView roDotNetTestDialog.dncFileView
)
)
createDialog roDotNetTestDialog 400 260
)
Akram
Akram
Technical Artist,
FxLabs Studios, India
http://akira-techart.blogspot.com/
|
|
|
|
Hi Akram,
thank you very much for that answer!
Few days back I came to the same resolution, but till now I had not the time to set it up. Your example is very good and helpful. Now I understand the main set up for the data grid and don’t have to find it by try and error.
Kind regards
Chris
|
|
|
|
|
|