(十八)c#Winform自定義控制項-提示框

来源:https://www.cnblogs.com/bfyx/archive/2019/08/16/11363756.html
-Advertisement-
Play Games

前提 入行已經7,8年了,一直想做一套漂亮點的自定義控制項,於是就有了本系列文章。 開源地址:https://gitee.com/kwwwvagaa/net_winform_custom_control 如果覺得寫的還行,請點個 star 支持一下吧 歡迎前來交流探討: 企鵝群568015492 目錄 ...


前提

入行已經7,8年了,一直想做一套漂亮點的自定義控制項,於是就有了本系列文章。

開源地址:https://gitee.com/kwwwvagaa/net_winform_custom_control

如果覺得寫的還行,請點個 star 支持一下吧

歡迎前來交流探討: 企鵝群568015492 企鵝群568015492

目錄

https://www.cnblogs.com/bfyx/p/11364884.html

準備工作

這是一個提示消息的窗體,他繼承自基類窗體FrmBase,如果你對FrmBase還不瞭解,請移步 (十七)c#Winform自定義控制項-基類窗體 查看

提示消息窗體支持有確定取消按鈕及單取消按鈕,更多操作按鈕暫沒有增加

開始

添加一個Form命名為FrmDialog ,繼承FrmBase

私有的構造函數

 1  private FrmDialog(
 2             string strMessage,
 3             string strTitle,
 4             bool blnShowCancel = false,
 5             bool blnShowClose = false,
 6             bool blnisEnterClose = true)
 7         {
 8             InitializeComponent();
 9             if (!string.IsNullOrWhiteSpace(strTitle))
10                 lblTitle.Text = strTitle;
11             lblMsg.Text = strMessage;
12             if (blnShowCancel)
13             {
14                 this.tableLayoutPanel1.ColumnStyles[1].Width = 1;
15                 this.tableLayoutPanel1.ColumnStyles[2].Width = 50;
16             }
17             else
18             {
19                 this.tableLayoutPanel1.ColumnStyles[1].Width = 0;
20                 this.tableLayoutPanel1.ColumnStyles[2].Width = 0;
21             }
22             btnClose.Visible = blnShowClose;
23             blnEnterClose = blnisEnterClose;
24         }

搭配一個靜態的公共函數

 1    #region 顯示一個模式信息框
 2         /// <summary>
 3         /// 功能描述:顯示一個模式信息框
 4         /// 作  者:HZH
 5         /// 創建日期:2019-03-04 15:49:48
 6         /// 任務編號:POS
 7         /// </summary>
 8         /// <param name="owner">owner</param>
 9         /// <param name="strMessage">strMessage</param>
10         /// <param name="strTitle">strTitle</param>
11         /// <param name="blnShowCancel">blnShowCancel</param>
12         /// <param name="isShowMaskDialog">isShowMaskDialog</param>
13         /// <param name="blnShowClose">blnShowClose</param>
14         /// <param name="isEnterClose">isEnterClose</param>
15         /// <returns>返回值</returns>
16         public static DialogResult ShowDialog(
17             IWin32Window owner,
18             string strMessage,
19             string strTitle = "提示",
20             bool blnShowCancel = false,
21             bool isShowMaskDialog = true,
22             bool blnShowClose = false,
23             bool blnIsEnterClose = true)
24         {
25             DialogResult result = DialogResult.Cancel;
26             if (owner == null || (owner is Control && (owner as Control).IsDisposed))
27             {
28                 result = new FrmDialog(strMessage, strTitle, blnShowCancel, blnShowClose, blnIsEnterClose)
29                 {
30                     StartPosition = FormStartPosition.CenterScreen,
31                     IsShowMaskDialog = isShowMaskDialog,
32                     TopMost = true
33                 }.ShowDialog();
34             }
35             else
36             {
37                 if (owner is Control)
38                 {
39                     owner = (owner as Control).FindForm();
40                 }
41                 result = new FrmDialog(strMessage, strTitle, blnShowCancel, blnShowClose, blnIsEnterClose)
42                 {
43                     StartPosition = (owner != null) ? FormStartPosition.CenterParent : FormStartPosition.CenterScreen,
44                     IsShowMaskDialog = isShowMaskDialog,
45                     TopMost = true
46                 }.ShowDialog(owner);
47             }
48             return result;
49         }
50         #endregion

一些小事件

 1 private void btnOK_BtnClick(object sender, EventArgs e)
 2         {
 3             this.DialogResult = System.Windows.Forms.DialogResult.OK;
 4         }
 5 
 6         private void btnCancel_BtnClick(object sender, EventArgs e)
 7         {
 8             this.DialogResult = System.Windows.Forms.DialogResult.Cancel;
 9         }
10 
11         private void btnClose_MouseDown(object sender, MouseEventArgs e)
12         {
13             this.DialogResult = System.Windows.Forms.DialogResult.Cancel;
14         }
15 
16         protected override void DoEnter()
17         {
18             if (blnEnterClose)
19                 this.DialogResult = System.Windows.Forms.DialogResult.OK;
20         }

代碼就這麼多,看下完整代碼

  1 // 版權所有  黃正輝  交流群:568015492   QQ:623128629
  2 // 文件名稱:FrmDialog.cs
  3 // 創建日期:2019-08-15 16:04:36
  4 // 功能描述:FrmDialog
  5 // 項目地址:https://gitee.com/kwwwvagaa/net_winform_custom_control
  6 using System;
  7 using System.Collections.Generic;
  8 using System.ComponentModel;
  9 using System.Data;
 10 using System.Drawing;
 11 using System.Linq;
 12 using System.Text;
 13 using System.Windows.Forms;
 14 
 15 namespace HZH_Controls.Forms
 16 {
 17     public partial class FrmDialog : FrmBase
 18     {
 19         bool blnEnterClose = true;
 20         private FrmDialog(
 21             string strMessage,
 22             string strTitle,
 23             bool blnShowCancel = false,
 24             bool blnShowClose = false,
 25             bool blnisEnterClose = true)
 26         {
 27             InitializeComponent();
 28             if (!string.IsNullOrWhiteSpace(strTitle))
 29                 lblTitle.Text = strTitle;
 30             lblMsg.Text = strMessage;
 31             if (blnShowCancel)
 32             {
 33                 this.tableLayoutPanel1.ColumnStyles[1].Width = 1;
 34                 this.tableLayoutPanel1.ColumnStyles[2].Width = 50;
 35             }
 36             else
 37             {
 38                 this.tableLayoutPanel1.ColumnStyles[1].Width = 0;
 39                 this.tableLayoutPanel1.ColumnStyles[2].Width = 0;
 40             }
 41             //btnCancel.Visible = blnShowCancel;
 42             //ucSplitLine_V1.Visible = blnShowCancel;
 43             btnClose.Visible = blnShowClose;
 44             blnEnterClose = blnisEnterClose;
 45             //if (blnShowCancel)
 46             //{
 47             //    btnOK.BtnForeColor = Color.FromArgb(255, 85, 51);
 48             //}
 49         }
 50 
 51         #region 顯示一個模式信息框
 52         /// <summary>
 53         /// 功能描述:顯示一個模式信息框
 54         /// 作  者:HZH
 55         /// 創建日期:2019-03-04 15:49:48
 56         /// 任務編號:POS
 57         /// </summary>
 58         /// <param name="owner">owner</param>
 59         /// <param name="strMessage">strMessage</param>
 60         /// <param name="strTitle">strTitle</param>
 61         /// <param name="blnShowCancel">blnShowCancel</param>
 62         /// <param name="isShowMaskDialog">isShowMaskDialog</param>
 63         /// <param name="blnShowClose">blnShowClose</param>
 64         /// <param name="isEnterClose">isEnterClose</param>
 65         /// <returns>返回值</returns>
 66         public static DialogResult ShowDialog(
 67             IWin32Window owner,
 68             string strMessage,
 69             string strTitle = "提示",
 70             bool blnShowCancel = false,
 71             bool isShowMaskDialog = true,
 72             bool blnShowClose = false,
 73             bool blnIsEnterClose = true)
 74         {
 75             DialogResult result = DialogResult.Cancel;
 76             if (owner == null || (owner is Control && (owner as Control).IsDisposed))
 77             {
 78                 result = new FrmDialog(strMessage, strTitle, blnShowCancel, blnShowClose, blnIsEnterClose)
 79                 {
 80                     StartPosition = FormStartPosition.CenterScreen,
 81                     IsShowMaskDialog = isShowMaskDialog,
 82                     TopMost = true
 83                 }.ShowDialog();
 84             }
 85             else
 86             {
 87                 if (owner is Control)
 88                 {
 89                     owner = (owner as Control).FindForm();
 90                 }
 91                 result = new FrmDialog(strMessage, strTitle, blnShowCancel, blnShowClose, blnIsEnterClose)
 92                 {
 93                     StartPosition = (owner != null) ? FormStartPosition.CenterParent : FormStartPosition.CenterScreen,
 94                     IsShowMaskDialog = isShowMaskDialog,
 95                     TopMost = true
 96                 }.ShowDialog(owner);
 97             }
 98             return result;
 99         }
100         #endregion
101 
102         private void btnOK_BtnClick(object sender, EventArgs e)
103         {
104             this.DialogResult = System.Windows.Forms.DialogResult.OK;
105         }
106 
107         private void btnCancel_BtnClick(object sender, EventArgs e)
108         {
109             this.DialogResult = System.Windows.Forms.DialogResult.Cancel;
110         }
111 
112         private void btnClose_MouseDown(object sender, MouseEventArgs e)
113         {
114             this.DialogResult = System.Windows.Forms.DialogResult.Cancel;
115         }
116 
117         protected override void DoEnter()
118         {
119             if (blnEnterClose)
120                 this.DialogResult = System.Windows.Forms.DialogResult.OK;
121         }
122 
123         private void FrmDialog_VisibleChanged(object sender, EventArgs e)
124         {
125             
126         }
127     }
128 }
View Code
  1 namespace HZH_Controls.Forms
  2 {
  3     partial class FrmDialog
  4     {
  5         /// <summary>
  6         /// Required designer variable.
  7         /// </summary>
  8         private System.ComponentModel.IContainer components = null;
  9 
 10         /// <summary>
 11         /// Clean up any resources being used.
 12         /// </summary>
 13         /// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
 14         protected override void Dispose(bool disposing)
 15         {
 16             if (disposing && (components != null))
 17             {
 18                 components.Dispose();
 19             }
 20             base.Dispose(disposing);
 21         }
 22 
 23         #region Windows Form Designer generated code
 24 
 25         /// <summary>
 26         /// Required method for Designer support - do not modify
 27         /// the contents of this method with the code editor.
 28         /// </summary>
 29         private void InitializeComponent()
 30         {
 31             System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(FrmDialog));
 32             this.btnClose = new System.Windows.Forms.Panel();
 33             this.panel1 = new System.Windows.Forms.Panel();
 34             this.tableLayoutPanel1 = new System.Windows.Forms.TableLayoutPanel();
 35             this.btnCancel = new HZH_Controls.Controls.UCBtnExt();
 36             this.ucSplitLine_V1 = new HZH_Controls.Controls.UCSplitLine_V();
 37             this.btnOK = new HZH_Controls.Controls.UCBtnExt();
 38             this.lblMsg = new System.Windows.Forms.Label();
 39             this.lblTitle = new System.Windows.Forms.Label();
 40             this.ucSplitLine_H1 = new HZH_Controls.Controls.UCSplitLine_H();
 41             this.ucSplitLine_H2 = new HZH_Controls.Controls.UCSplitLine_H();
 42             this.panel1.SuspendLayout();
 43             this.tableLayoutPanel1.SuspendLayout();
 44             this.SuspendLayout();
 45             // 
 46             // btnClose
 47             // 
 48             this.btnClose.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
 49             this.btnClose.BackgroundImage = global::HZH_Controls.Properties.Resources.dialog_close;
 50             this.btnClose.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Zoom;
 51             this.btnClose.Location = new System.Drawing.Point(383, 0);
 52             this.btnClose.Name = "btnClose";
 53             this.btnClose.Size = new System.Drawing.Size(28, 60);
 54             this.btnClose.TabIndex = 4;
 55             this.btnClose.MouseDown += new System.Windows.Forms.MouseEventHandler(this.btnClose_MouseDown);
 56             // 
 57             // panel1
 58             // 
 59             this.panel1.Controls.Add(this.tableLayoutPanel1);
 60             this.panel1.Dock = System.Windows.Forms.DockStyle.Bottom;
 61             this.panel1.Location = new System.Drawing.Point(0, 214);
 62             this.panel1.Name = "panel1";
 63             this.panel1.Size = new System.Drawing.Size(427, 64);
 64             this.panel1.TabIndex = 3;
 65             // 
 66             // tableLayoutPanel1
 67             // 
 68             this.tableLayoutPanel1.ColumnCount = 3;
 69             this.tableLayoutPanel1.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 50F));
 70             this.tableLayoutPanel1.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Absolute, 1F));
 71             this.tableLayoutPanel1.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 50F));
 72             this.tableLayoutPanel1.Controls.Add(this.btnCancel, 2, 0);
 73             this.tableLayoutPanel1.Controls.Add(this.ucSplitLine_V1, 1, 0);
 74             this.tableLayoutPanel1.Controls.Add(this.btnOK, 0, 0);
 75             this.tableLayoutPanel1.Dock = System.Windows.Forms.DockStyle.Fill;
 76             this.tableLayoutPanel1.Location = new System.Drawing.Point(0, 0);
 77             this.tableLayoutPanel1.Margin = new System.Windows.Forms.Padding(0);
 78             this.tableLayoutPanel1.Name = "tableLayoutPanel1";
 79             this.tableLayoutPanel1.RowCount = 1;
 80             this.tableLayoutPanel1.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 100F));
 81             this.tableLayoutPanel1.Size = new System.Drawing.Size(427, 64);
 82             this.tableLayoutPanel1.TabIndex = 5;
 83             // 
 84             // btnCancel
 85             // 
 86             this.btnCancel.BackColor = System.Drawing.Color.Transparent;
 87             this.btnCancel.BtnBackColor = System.Drawing.Color.Transparent;
 88             this.btnCancel.BtnFont = new System.Drawing.Font("微軟雅黑", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
 89             this.btnCancel.BtnForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(73)))), ((int)(((byte)(119)))), ((int)(((byte)(232)))));
 90             this.btnCancel.BtnText = "取消";
 91             this.btnCancel.ConerRadius = 5;
 92             this.btnCancel.Cursor = System.Windows.Forms.Cursors.Hand;
 93             this.btnCancel.Dock = System.Windows.Forms.DockStyle.Fill;
 94             this.btnCancel.FillColor = System.Drawing.Color.White;
 95             this.btnCancel.Font = new System.Drawing.Font("微軟雅黑", 15F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Pixel);
 96             this.btnCancel.IsRadius = false;
 97             this.btnCancel.IsShowRect = false;
 98             this.btnCancel.IsShowTips = false;
 99             this.btnCancel.Location = new System.Drawing.Point(214, 0);
100             this.btnCancel.Margin = new System.Windows.Forms.Padding(0);
101             this.btnCancel.Name = "btnCancel";
102             this.btnCancel.RectColor = System.Drawing.Color.FromArgb(((int)(((byte)(247)))), ((int)(((byte)(247)))), ((int)(((byte)(247)))));
103             this.btnCancel.RectWidth = 1;
104             this.btnCancel.Size = new System.Drawing.Size(213, 64);
105             this.btnCancel.TabIndex = 1;
106             this.btnCancel.TabStop = false;
107             this.btnCancel.TipsText = "";
108             this.btnCancel.BtnClick += new System.EventHandler(this.btnCancel_BtnClick);
109             // 
110             // ucSplitLine_V1
111             // 
112             this.ucSplitLine_V1.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(238)))), ((int)(((byte)(238)))), ((int)(((byte)(238)))));
113             this.ucSplitLine_V1.Dock = System.Windows.Forms.DockStyle.Fill;
114             this.ucSplitLine_V1.Location = new System.Drawing.Point(213, 15);
115             this.ucSplitLine_V1.Margin = new System.Windows.Forms.Padding(0, 15, 0, 15);
116             this.ucSplitLine_V1.Name = "ucSplitLine_V1";
117             this.ucSplitLine_V1.Size = new System.Drawing.Size(1, 34);
118             this.ucSplitLine_V1.TabIndex = 2;
119             this.ucSplitLine_V1.TabStop = false;
120             // 
121             // btnOK
122             // 
123             this.btnOK.BackColor = System.Drawing.Color.Transparent;
124             this.btnOK.BtnBackColor = System.Drawing.Color.Transparent;
125             this.btnOK.BtnFont = new System.Drawing.Font("微軟雅黑", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
126             this.btnOK.BtnForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(255)))), ((int)(((byte)(77)))), ((int)(((byte)(59)))));
127             this.btnOK.BtnText = "確定";
128             this.btnOK.ConerRadius = 5;
129             this.btnOK.Cursor = System.Windows.Forms.Cursors.Hand;
130             this.btnOK.Dock = System.Windows.Forms.DockStyle.Fill;
131             this.btnOK.FillColor = System.Drawing.Color.White;
132             this.btnOK.Font = new System.Drawing.Font("微軟雅黑", 15F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Pixel);
133             this.btnOK.ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(255)))), ((int)(((byte)(77)))), ((int)(((byte)(59)))));
134             this.btnOK.IsRad

您的分享是我們最大的動力!

-Advertisement-
Play Games
更多相關文章
  • 前提 入行已經7,8年了,一直想做一套漂亮點的自定義控制項,於是就有了本系列文章。 開源地址:https://gitee.com/kwwwvagaa/net_winform_custom_control 如果覺得寫的還行,請點個 star 支持一下吧 歡迎前來交流探討: 企鵝群568015492 目錄 ...
  • 前提 入行已經7,8年了,一直想做一套漂亮點的自定義控制項,於是就有了本系列文章。 開源地址:https://gitee.com/kwwwvagaa/net_winform_custom_control 如果覺得寫的還行,請點個 star 支持一下吧 歡迎前來交流探討: 企鵝群568015492 目錄 ...
  • 前提 入行已經7,8年了,一直想做一套漂亮點的自定義控制項,於是就有了本系列文章。 開源地址:https://gitee.com/kwwwvagaa/net_winform_custom_control 如果覺得寫的還行,請點個 star 支持一下吧 歡迎前來交流探討: 企鵝群568015492 目錄 ...
  • 前提 入行已經7,8年了,一直想做一套漂亮點的自定義控制項,於是就有了本系列文章。 開源地址:https://gitee.com/kwwwvagaa/net_winform_custom_control 如果覺得寫的還行,請點個 star 支持一下吧 歡迎前來交流探討: 企鵝群568015492 目錄 ...
  • 前提 入行已經7,8年了,一直想做一套漂亮點的自定義控制項,於是就有了本系列文章。 開源地址:https://gitee.com/kwwwvagaa/net_winform_custom_control 如果覺得寫的還行,請點個 star 支持一下吧 歡迎前來交流探討: 企鵝群568015492 目錄 ...
  • 前提 入行已經7,8年了,一直想做一套漂亮點的自定義控制項,於是就有了本系列文章。 開源地址:https://gitee.com/kwwwvagaa/net_winform_custom_control 如果覺得寫的還行,請點個 star 支持一下吧 歡迎前來交流探討: 企鵝群568015492 目錄 ...
  • 前提 入行已經7,8年了,一直想做一套漂亮點的自定義控制項,於是就有了本系列文章。 開源地址:https://gitee.com/kwwwvagaa/net_winform_custom_control 如果覺得寫的還行,請點個 star 支持一下吧 歡迎前來交流探討: 企鵝群568015492 目錄 ...
  • 前提 入行已經7,8年了,一直想做一套漂亮點的自定義控制項,於是就有了本系列文章。 開源地址:https://gitee.com/kwwwvagaa/net_winform_custom_control 如果覺得寫的還行,請點個 star 支持一下吧 歡迎前來交流探討: 企鵝群568015492 目錄 ...
一周排行
    -Advertisement-
    Play Games
  • 移動開發(一):使用.NET MAUI開發第一個安卓APP 對於工作多年的C#程式員來說,近來想嘗試開發一款安卓APP,考慮了很久最終選擇使用.NET MAUI這個微軟官方的框架來嘗試體驗開發安卓APP,畢竟是使用Visual Studio開發工具,使用起來也比較的順手,結合微軟官方的教程進行了安卓 ...
  • 前言 QuestPDF 是一個開源 .NET 庫,用於生成 PDF 文檔。使用了C# Fluent API方式可簡化開發、減少錯誤並提高工作效率。利用它可以輕鬆生成 PDF 報告、發票、導出文件等。 項目介紹 QuestPDF 是一個革命性的開源 .NET 庫,它徹底改變了我們生成 PDF 文檔的方 ...
  • 項目地址 項目後端地址: https://github.com/ZyPLJ/ZYTteeHole 項目前端頁面地址: ZyPLJ/TreeHoleVue (github.com) https://github.com/ZyPLJ/TreeHoleVue 目前項目測試訪問地址: http://tree ...
  • 話不多說,直接開乾 一.下載 1.官方鏈接下載: https://www.microsoft.com/zh-cn/sql-server/sql-server-downloads 2.在下載目錄中找到下麵這個小的安裝包 SQL2022-SSEI-Dev.exe,運行開始下載SQL server; 二. ...
  • 前言 隨著物聯網(IoT)技術的迅猛發展,MQTT(消息隊列遙測傳輸)協議憑藉其輕量級和高效性,已成為眾多物聯網應用的首選通信標準。 MQTTnet 作為一個高性能的 .NET 開源庫,為 .NET 平臺上的 MQTT 客戶端與伺服器開發提供了強大的支持。 本文將全面介紹 MQTTnet 的核心功能 ...
  • Serilog支持多種接收器用於日誌存儲,增強器用於添加屬性,LogContext管理動態屬性,支持多種輸出格式包括純文本、JSON及ExpressionTemplate。還提供了自定義格式化選項,適用於不同需求。 ...
  • 目錄簡介獲取 HTML 文檔解析 HTML 文檔測試參考文章 簡介 動態內容網站使用 JavaScript 腳本動態檢索和渲染數據,爬取信息時需要模擬瀏覽器行為,否則獲取到的源碼基本是空的。 本文使用的爬取步驟如下: 使用 Selenium 獲取渲染後的 HTML 文檔 使用 HtmlAgility ...
  • 1.前言 什麼是熱更新 游戲或者軟體更新時,無需重新下載客戶端進行安裝,而是在應用程式啟動的情況下,在內部進行資源或者代碼更新 Unity目前常用熱更新解決方案 HybridCLR,Xlua,ILRuntime等 Unity目前常用資源管理解決方案 AssetBundles,Addressable, ...
  • 本文章主要是在C# ASP.NET Core Web API框架實現向手機發送驗證碼簡訊功能。這裡我選擇是一個互億無線簡訊驗證碼平臺,其實像阿裡雲,騰訊雲上面也可以。 首先我們先去 互億無線 https://www.ihuyi.com/api/sms.html 去註冊一個賬號 註冊完成賬號後,它會送 ...
  • 通過以下方式可以高效,並保證數據同步的可靠性 1.API設計 使用RESTful設計,確保API端點明確,並使用適當的HTTP方法(如POST用於創建,PUT用於更新)。 設計清晰的請求和響應模型,以確保客戶端能夠理解預期格式。 2.數據驗證 在伺服器端進行嚴格的數據驗證,確保接收到的數據符合預期格 ...