1. 程式人生 > >使用 C# 開發智能手機軟件:推箱子(十四)

使用 C# 開發智能手機軟件:推箱子(十四)

sign pos 智能 hbox post form www .text font

這是“使用 C# 開發智能手機軟件:推箱子”系列文章的第十四篇。在這篇文章中,介紹 Window/ErrorMsgDlg.cs 源程序文件。這個源程序文件包括 ErrorMsgDlg 類。該類繼承自 System.Windows.Forms.Form 類,表示推箱子的“錯誤信息”對話框。例如以下圖所看到的:

技術分享 技術分享

技術分享

以下是 Window/ErrorMsgDlg.Designer.cs 源程序的部分代碼:

namespace Skyiv.Ben.PushBox.Window
{
public partial class ErrorMsgDlg
{

// 這裏省略了一些代碼 技術分享

private System.Windows.Forms.TabControl tclMain;
private System.Windows.Forms.TabPage tpgBase;
private System.Windows.Forms.TabPage tpgAdv;
private System.Windows.Forms.TextBox tbxBase;
private System.Windows.Forms.TextBox tbxAdv;
}
}

在“錯誤信息”對話框中,用一個 TabControl 控件來管理相關的選項卡頁集,分為“簡明”和“具體”兩個選項卡(TabPage 控件)。每一個選項卡中使用 TextBox 控件來顯示相關的信息。以下是 Window/ErrorMsgDlg.cs 源程序的代碼:


1 using System.Windows.Forms;
2
3 namespace Skyiv.Ben.PushBox.Window
4 {
5 /// <summary>
6 /// “錯誤信息”對話框
7 /// </summary>
8 public partial class ErrorMsgDlg : Form
9 {
10 public string ErrorMsg { set { tbxBase.Text = value; } }
11 public string DebugMsg {
set { tbxAdv.Text = value; } }
12
13 public ErrorMsgDlg(bool isTopMost)
14 {
15 InitializeComponent();
16 TopMost = isTopMost;
17 }
18 }
19 }

使用 C# 開發智能手機軟件:推箱子(十四)