Notifications
Clear all
[Closed] dotnet checkbox in datagridview
Mar 16, 2015 9:51 pm
How can i style the checkbox to appear as a checkbutton in the first column of the datagrid view?
I want to set it’s background color as well.
try(destroyDialog ::rlTest)catch()
rollout rlTest ""
(
local alignmentClass = dotNetClass "System.Windows.Forms.DataGridViewContentAlignment"
local selectionClass = dotNetClass "System.Windows.Forms.DataGridViewSelectionMode"
local colMaxBg = (colorMan.getColor #background)*255
local colorClass = dotNetClass "system.drawing.color"
local colMax = colorClass.fromArgb colMaxBg[1] colMaxBg[2] colMaxBg[3]
dotNetControl dgv "DataGridView" height:380 width:280 pos:[10,10]
on rlTest open do
(
clearlistener()
-- stylizing
dgv.AllowUserToAddRows = false
dgv.AllowUserToDeleteRows = false
dgv.AllowUserToResizeRows = false
dgv.AllowUserToResizeColumns = false
dgv.ShowEditingIcon = false
dgv.RowHeadersVisible = false
dgv.ColumnHeadersVisible = false
dgv.AutoSizeColumnsMode = dgv.AutoSizeColumnsMode.Fill
--showproperties dgv.AutoSizeColumnsMode
--dgv.SelectionMode = selectionClass.FullRowSelect
dgv.ForeColor = colMax
dgv.BackColor = colMax
dgv.GridColor = colMax
dgv.Backgroundcolor = colMax
--showproperties dgv
-- adding columns
columnHeaders = #("On/Off","Action","Fix")
columnWidths = #(10,80,10)
columnTypes = #(dotNetObject "DataGridViewCheckBoxColumn", dotNetObject "DataGridViewButtonColumn", dotNetObject "DataGridViewButtonColumn")
for i = 1 to 3 do
(
newColumn = columnTypes[i]
newColumn.headerText = columnHeaders[i]
newColumn.ReadOnly = false
newColumn.DefaultCellStyle.Alignment = alignmentClass.MiddleCenter
--newColumn.width = (dgv.width - 1) * columnWidths[i] * .01
dgv.columns.add newColumn
if i == 1 do
(
showproperties newcolumn
newcolumn.FlatStyle = newcolumn.FlatStyle.Flat
--ctrl.appearance = ctrl.appearance.Button
)
)
-- adding cells
for i = 1 to 10 do
(
newRow = dotNetObject "DataGridViewRow"
newRow.height = 30
dgv.rows.add newRow
newRow.cells.item[0].value = true
newRow.cells.item[1].value = "great"
newRow.cells.item[2].value = "+"
)
dgv.columns.item[0].width = 20
dgv.columns.item[2].width = 30
--showproperties dgv.Rows.item[0]
)
)
createDialog rlTest 300 400
1 Reply
Mar 16, 2015 9:51 pm
Don’t know about the checkbutton (is it a radiobutton ?) but for the background you can set the backColor in cells style :
newColumn.DefaultCellStyle.BackColor = colMax