You must Sign In to post a response.
  • Category: ASP.NET

    Pass font from fontdialog box in DrawString

    hi i want to pass font name,size from font dialog box to do this

    DrawString(TextBox1.Text, FontDialog1.Font.Name, ColorDialog1.Color, New Point(0, gY))

    DrawString(TextBox1.Text, New Font(FontDialog1.Font.Name, FontDialog1.Font.Size), Brushes.Orange, New Point(0, gY))

    both the above statements are giving error
  • #347507
    Hi juhee

    You cannot pass colordialog as paramater to drawstring.Use the following

    protected override void OnPaint(System.Windows.Forms.PaintEventArgs e)
    Graphics g = e.Graphics; SolidBrush brush =
    new SolidBrush(colorDialog1.Color);
    Pen pen = new Pen(Color.Black);
    SizeF sizef = g.MeasureString(this.Text, this.Font);
    PointF pointf = new PointF(0, 0);

    g.DrawString("test",fontDialog1.Font,brush,new Point(0,10));

    private void Form1_Load(object sender, EventArgs e)


  • This thread is locked for new responses. Please post your comments and questions as a separate thread.
    If required, refer to the URL of this page in your new post.