Text 2D sur un panel

goldziko9 Messages postés 39 Date d'inscription lundi 3 janvier 2005 Statut Membre Dernière intervention 5 avril 2010 - 27 juil. 2007 à 13:36
Lutinore Messages postés 3246 Date d'inscription lundi 25 avril 2005 Statut Membre Dernière intervention 27 octobre 2012 - 27 juil. 2007 à 14:16
Salut tous le monde.
   Voila, c'est la premier fois que je veux faire du designe avec C#, alors j'ai voulu ecrire une petit fonction qui fera tous ça.

  public void put_text(string msg)
  {
   Font fnt = new Font(FontFamily.GenericSansSerif,0.1f);
   Brush bb = new SolidBrush(Color.White);
   Graphics gg = Graphics.FromHdc(panel1.Handle);
   gg.DrawString(msg,fnt,bb,3,4);
   panel1.Refresh();
  }

mais malheuresement ça m'affiche un message d'erreur : Memoire insuffisante.

1 réponse

Lutinore Messages postés 3246 Date d'inscription lundi 25 avril 2005 Statut Membre Dernière intervention 27 octobre 2012 41
27 juil. 2007 à 14:16
Salut,

private void DrawString( string s )
{
    using ( Graphics g = myPanel.CreateGraphics( ) )
    {
        g.Clear( myPanel.BackColor );
        g.DrawString( s, myPanel.Font, Brushes.White, 10.0f, 10.0f );
    } // Dispose
}
0
Rejoignez-nous