2012-11-08 56 views
1

我有這樣的代碼如何在C#代碼的消息框中使字符串變量的字體顏色爲紅色?

public static bool Delete(int ID, string ProductName) 
    { 
     if (MessageBox.Show(productName + " will be deleted Permanently ", "Confirm Delete Option", MessageBoxButtons.YesNo, MessageBoxIcon.Warning) == DialogResult.No) 
      { 
       return false; 
      } 
     { 
      return true; 
     } 
    } 

什麼,我需要的就是讓產品名稱在下面的紅色消息框顏色

if (MessageBox.Show(productName + " will be deleted Permanently " 
+2

恐怕您必須製作自己的自定義消息框 – slawekwin

+1

您無法做到這一點必須製作一個你自己。請參閱:http://social.msdn.microsoft.com/Forums/en/winforms/thread/7e5b9237-7502-4eba-aaed-48ebce2ce8a7和http://stackoverflow.com/questions/2259027/bold-text-in- messagebox – Habib

+1

@ SQL.NET有什麼'html'與這個問題有關? – freebird

回答

1

不能用的MessageBox來完成。

您需要根據需要使用佈局定義自己的窗體,然後以模態方式顯示它。

5

你必須爲此創建自己的窗體。 在那裏你創建一個標籤並定義你的字體。 之後,您可以定義您的noyes按鈕。

private void No_button_Click(object sender, EventArgs e) 
{ 
    this.DialogResult = DialogResult.No; 
    this.Close(); 
    this.Close(); 
} 

同爲yes按鈕 有通過例如創建自己的形式多等優勢定義位置。

相關問題