簡體   English   中英

用戶定義的繪畫不可見

[英]User defined painting not visible

我有一個Windows窗體應用程序,其中包含一個GroupBox和一個PictureBox作為背景圖像,以及一些來自PowerPack的可單擊OvalShapes。

現在我需要一些用於OvalShapes的標簽,因此我將EventHandler放在GroupBox上,每次重繪時,都應繪制以下內容

this.groupBoxTest.Paint += new System.Windows.Forms.PaintEventHandler(this.groupBoxVirtualView_Paint);

private void groupBoxVirtualView_Paint(object sender, PaintEventArgs e)
{
    Graphics g = groupBoxVirtualView.CreateGraphics();//e.Graphics;
    g.DrawString("01", new Font("Arial", 12), new SolidBrush(Color.Black), 240, 115);
}

但是字符串01永遠不會被繪制; 我所看到的只是位於同一位置的橢圓形-出於測試目的禁用它們也不起作用。

我的琴弦怎么了?

還有其他方式標記我的PoweredOval嗎?

你必須用

groupBoxVirtualView.Invalidate();

重繪groupBox!

paint事件應使用來自發送者的圖形對象:

private void groupBoxVirtualView_Paint(object sender, PaintEventArgs e)
{
  Graphics g = e.Graphics;
  g.DrawString("01", new Font("Arial", 12), new SolidBrush(Color.Black), 240, 115);
}

另外,如果GroupBox內有一個PictureBox,則該控件將不會顯示要通過該控件的任何GroupBox繪畫。 它會隱藏它。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM