i need display image in cell header. problem i'm using class contains various methods gui , can't figure out how use cellpaint event in class. there way how can update class, same way update cell value or has cellpaint event? thanks!
edit:
class gui { public void fixgridcells(datagridview grid){ } public void assigncellimages(datagridview grid){ grid.column[0].header = myimage; // <-- need } } // myform.cs myform_load(){ gui gui = new gui(); gui.fixgridsize(mygrid); gui.assigncellimages(mygrid); // <-- need call }
first of all, need create image object image file.
image iconimg = image.fromfile("c:\\logo.jpg");
after use datagridview cell painting event.
private void datagridview1_cellpainting(system.object sender, system.windows.forms.datagridviewcellpaintingeventargs e) { if (e.rowindex == -1 && e.columnindex == datagridview1.columns.count - 1) { e.paint(e.cellbounds, datagridviewpaintparts.all & !datagridviewpaintparts.contentforeground); e.graphics.drawimage(iconimg, e.cellbounds); e.handled = true; } }
hope help.
Comments
Post a Comment