vb.net - Datagridview CheckboxColumn Shaded or (X) Mark when unchecked -
good morning
i have column in datagridview
generates checkbox , in relation have lot of columns in table called 2016,2017 , on
, of tinyint
now here image both of them:
now here question, instead of uncheck how can make shaded or x mark in datagridview
column?
here code in populating datagridview
:
dim sql1 mysqlcommand = new mysqlcommand("select * period_closure", con1) dim ds1 dataset = new dataset dim adapter1 mysqldataadapter = new mysqldataadapter con1.open() adapter1.selectcommand = sql1 adapter1.fill(ds1, "mytable") datagridview1.datasource = ds1.tables(0) con1.close() ds1.tables(0).columns(2).datatype = gettype(boolean) me.datagridview1.columns(0).frozen = true dim integer = 0 datagridview1.columns.count - 1 datagridview1.columns.item(i).sortmode = datagridviewcolumnsortmode.programmatic next datagridview1.columns("periodid").visible = false datagridview1.columns(0).defaultcellstyle.backcolor = color.lightblue
first of download 'x' image in google, or create own.
then try add in code.
private sub checkbox1_paint(sender object, e painteventargs) handles checkbox1.paint if checkbox1.checked = false try dim newimage image = image.fromfile("e:\projects\library\ber-x.jpg") dim x single = 0 dim y single = 0 dim width single = checkbox1.width 'you can try checkbox1.width - 3 dim height single = checkbox1.height 'you can try checkbox1.height - 3 e.graphics.drawimage(newimage, x, y, width, height) catch ex exception end try end if end sub
the x
mark in checkbox not accurate in position can fix self. try , explore fit in system. :)
hope you.
Comments
Post a Comment