c# - Image and value into a GridView cell -


i have xtragridview bound datasource via linq, when check checkbox need set image cell , value have. right when check checkbox set image in cell fine eliminate cell value (the data). on customdrawcell event this

private void gridview_gd_customdrawcell(object sender, rowcellcustomdraweventargs e)         {                             gridview view = sender gridview;                 string evento1 = convert.tostring(view.getrowcellvalue(e.rowhandle, "eve1"));              if (cvariables.ficon_estado == 1)             {                 if (evento1 == "06" || evento1 == "15")                 {                     if (e.column.fieldname == "g1")                     {                         e.handled = true;                         point pos = calcposition(e, imagecollection_16.images[1]);                         e.graphics.drawimage(imagecollection_16.images[1], pos);                         view.columns["g1"].appearancecell.backcolor = color.transparent;                         view.columns["g1"].appearancecell.textoptions.halignment = devexpress.utils.horzalignment.far;                                             }                 }             }             else             {                 view.columns["g1"].appearancecell.textoptions.halignment = devexpress.utils.horzalignment.center;             } }   private point calcposition(rowcellcustomdraweventargs e, image img)         {             point p = new point();             p.x = e.bounds.location.x + (e.bounds.width - (img.width * 3)) / 2;             p.y = e.bounds.location.y + (e.bounds.height - img.height) / 2;             return p;         } 

i post image illustrate want

a cell text disappears since set e.handled property true. when option set, default painting mechanism not invoked. can still draw cell text manually using e.appearance.drawstring method.

e.appearance.drawstring(e.cache, e.displaytext, e.bounds); 

another solution show image using repositoryitemtextedit.contextimage. is, can create 2 repositoryitemtextedits different context images , assign them grid cells conditionally in gridview.customrowcelledit event handler.


Comments

Popular posts from this blog

inversion of control - Autofac named registration constructor injection -

verilog - Systemverilog dynamic casting issues -

ios - Change Storyboard View using Seague -