0

After some search at Google I had some examples but none of them gave me what I need.

I need to write a String (WriteString()) into a Control in WinForm on a ButtonClick and I need to update that Draw, because i'm trying to write the Date into the Control, the System Date.

So each time the user clicks on that Button the DateTime.Now.ToString(); should be drawn into the Control.

Bests

harryovers
  • 3,087
  • 2
  • 34
  • 56
Rosmarine Popcorn
  • 10,761
  • 11
  • 59
  • 89

3 Answers3

0

You should consider using a winforms Label and a Timer for that.

aL3891
  • 6,205
  • 3
  • 33
  • 37
  • Yes but if i use Label into a Video Player Control ,the Label is Showing is' Background ,i need it transparent (The Background). – Rosmarine Popcorn Jun 30 '11 at 09:28
  • you can try setting the label [background](http://msdn.microsoft.com/en-us/library/system.windows.forms.control.backcolor.aspx) color to [Transparent](http://msdn.microsoft.com/en-us/library/system.drawing.color.transparent.aspx) but that may or may not work depending on how you're rendering the video – aL3891 Jun 30 '11 at 09:31
0

Or you could modify the OnPaint method of the control to override how the control is painted. There is a method in the Graphics object that lets you write a string g.DrawString

Ignacio Soler Garcia
  • 21,122
  • 31
  • 128
  • 207
0

draw a string on label

this url will surely help you

the code written there is

void Label_OnPaint(object sender, PaintEventArgs e) {
  base.OnPaint(e);
  Label lbl = sender as Label;
  if (lbl != null) {
    string Text = lbl.Text;
    e.Graphics.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.AntiAlias;
    if (myShowShadow) { // draw the shadow first!
      e.Graphics.DrawString(Text, lbl.Font, new SolidBrush(myShadowColor), myShadowOffset, StringFormat.GenericDefault);
    }
    e.Graphics.DrawString(Text, lbl.Font, new SolidBrush(lbl.ForeColor), 0, 0, StringFormat.GenericDefault);
  }
}
Community
  • 1
  • 1
rahularyansharma
  • 11,156
  • 18
  • 79
  • 135