在我的mainForm中,我檢查Form_Load中已安裝的compoenets。如果他們沒有安裝,我打電話給另一個窗體(WaitingDialog)來顯示instalaltion的狀態。我叫waitingDialog爲:從mainForm調用其他窗體 - 其他窗體不可見的組件
waitDlg = new WaitingDialog(null); // Parent is set to null
waitDlg.set("Checking....", "Components"); // Set 2 Labels
waitDlg.Title = "Installing...";
waitDlg.Show();
與上面的代碼等待形式是可見的,但興田文本集是不可見的。該部分(文字大小)的標籤是白色背景,但沒有文字可見。
我必須在Form_Load中只執行mainForm,就好像componetns不存在那麼mainForm安裝它,並且approp消息顯示在waitingDlg窗體上。
如何在waitDlg表單中以文本顯示的方式處理此問題?
WaitingDialog代碼:
public partial class WaitingDialog : Form
{
private string title;
private string message;
private bool cancel;
private ParentForm myParent = null;
public WaitingDialog()
{
InitializeComponent();
Cancel = false;
this.StartPosition = FormStartPosition.CenterScreen;
}
public WaitingDialog(ParentForm parent) : this()
{
if (parent != null)
{
myParent = parent;
this.StartPosition = FormStartPosition.Manual;
}
}
public WaitingDialog(string title, string message)
: this()
{
label1.Text = title;
msgLbl.Text = message;
// Title = title;
// Message = message;
}
private void WaitingDialog_Load(object sender, EventArgs e)
{
}
public string Title
{
get { return title; }
set { title = value;
label1.Text = title;
Invalidate();
}
}
public string Message
{
get { return message; }
set { message = value;
msgLbl.Text = value;
Invalidate();
}
}
public void set(string title, string message)
{
Title = title;
Message = message;
}
public void set(string title, string message, bool showButton)
{
Title = title;
Message = message;
this.cancelBtn.Visible = showButton;
}
public void showCancelButton(bool showButton)
{
this.cancelBtn.Visible = showButton;
}
public bool Cancel
{
get { return cancel; }
set { cancel = value; }
}
private void cancelBtn_Click(object sender, EventArgs e)
{
Console.WriteLine("CANCEL BUTTON CAUGHT");
Cancel = true;
}
}
// TRIED CAlling as :
waitingDlg = new WaitingDialog("Installing", "Components");
waitingDlg.Text = "Install Components"; //CAN SEE THIS IN TITLE
waitingDlg.Show();
但標籤的文本可以是不可見的和背景(文本的大小)是白色的。
希望這會有所幫助。如果你需要更多,會很高興分享更多。
謝謝
你在waitDlg中的set方法是什麼? – Kamyar
您在創建表單時將標籤和標題設置爲常量值。你能在設計師中設置這些標籤和標題嗎? –
你可以發佈WaitingDialog的som代碼嗎? – Bassetassen