c# - Draw an image out of a control -


i have control. it's text box. want draw image @ left of control. image should painted outside control. paint 1 inside.

here code:

  private static image requiredicon = resources.icon_required;   protected override void onpaint(painteventargs e)   {      base.onpaint(e);      if (base.enabled && string.isnullorempty(base.text))      {         e.graphics.drawimage(requiredicon, 0, 0);      }   } 

instead of drawing image, create appropriate control, e.g. picturebox, it's image property set appropriate image resource.

it may easier @ design time rather run time. if image should not shown intitially, set it's visible property false @ design time , set true @ run time when image should shown.


Comments

Popular posts from this blog

android - Spacing between the stars of a rating bar? -

html - Instapaper-like algorithm -

c# - How to execute a particular part of code asynchronously in a class -