/// <summary>
/// 數據源
/// </summary>
private DataTable g_dtSource = new DataTable();
#region InitGrid 初始化Grid標題信息
/// <summary>
/// 初始化Grid標題信息
/// </summary>
private void InitGrid()
{
this.g_dtSource.Clear();
this.g_dtSource.Columns.Add("DeviceCode", typeof(string)).ReadOnly = true;
this.g_dtSource.Columns.Add("SlotName", typeof(string)).ReadOnly = true;
this.g_dtSource.Columns.Add("MitemCode", typeof(string)).ReadOnly = true;
this.g_dtSource.Columns.Add("LoadStatus", typeof(string)).ReadOnly = true;
this.dgInfo.DataSource = this.g_dtSource;
DataGridTableStyle dgtStyle = new DataGridTableStyle();
if (this.dgInfo.TableStyles.Count == 0)
{
this.dgInfo.TableStyles.Add(dgtStyle);
dgtStyle.GridColumnStyles[0].HeaderText = "設備";
dgtStyle.GridColumnStyles[0].MappingName = "DeviceCode";
dgtStyle.GridColumnStyles[0].NullText = "";
dgtStyle.GridColumnStyles[0].Width = 50;
dgtStyle.GridColumnStyles[1].HeaderText = "棧位";
dgtStyle.GridColumnStyles[1].MappingName = "SlotName";
dgtStyle.GridColumnStyles[1].NullText = "";
dgtStyle.GridColumnStyles[1].Width = 60;
dgtStyle.GridColumnStyles[2].HeaderText = "物料編碼";
dgtStyle.GridColumnStyles[2].MappingName = "MitemCode";
dgtStyle.GridColumnStyles[2].NullText = "";
dgtStyle.GridColumnStyles[2].Width = 60;
dgtStyle.GridColumnStyles[3].HeaderText = "上料狀態";
dgtStyle.GridColumnStyles[3].MappingName = "LoadStatus";
dgtStyle.GridColumnStyles[3].NullText = "";
dgtStyle.GridColumnStyles[3].Width = 60;
}
}
#endregion
#region 選中整行
private void dgInfo_CurrentCellChanged(object sender, EventArgs e)
{
this.dgInfo.Select(this.dgInfo.CurrentRowIndex);
}
#endregion
//循環處理
for (int i = 0; i < this.g_dtSource.Rows.Count; i++)
{
if (this.g_dtSource.Rows[i]["SlotName"].ToString() == SloatName)
{
bSloatName = true;
currMitemCode = this.g_dtSource.Rows[i]["MitemCode"].ToString();
//bool bEqualMitemCode = false;
//bEqualMitemCode = this.txtMitem.Text.IndexOf(currMitemCode) > 0; 不能確認是這樣
//當前棧位的物料 是否 與掃描的物料的UID 一致
if (ScanMitemCode == currMitemCode)
//if (bEqualMitemCode)
{
//匹配成功修改為Y
this.g_dtSource.Columns["LoadStatus"].ReadOnly = false;
this.g_dtSource.Rows[i]["LoadStatus"] = "Y";
this.dgInfo.Select(i); //設置選中
this.txtMitem.Text = "";
this.txtSloatName.Text = "";
this.txtMitem.Focus();
}
else
{
this.txtMitem.SelectAll();
this.SetMsg("上料表的物料和料盤的物料不一致!", Color.Red);
break;
//return;
}
}
if (this.g_dtSource.Rows[i]["LoadStatus"].ToString() == "Y")
{
iFinishCnt++;
}
}
另外有需要云服務器可以了解下創新互聯scvps.cn,海內外云服務器15元起步,三天無理由+7*72小時售后在線,公司持有idc許可證,提供“云服務器、裸金屬服務器、高防服務器、香港服務器、美國服務器、虛擬主機、免備案服務器”等云主機租用服務以及企業上云的綜合解決方案,具有“安全穩定、簡單易用、服務可用性高、性價比高”等特點與優勢,專為企業上云打造定制,能夠滿足用戶豐富、多元化的應用場景需求。
本文標題:datagrid使用-創新互聯
網站地址:http://vcdvsql.cn/article32/pgisc.html
成都網站建設公司_創新互聯,為您提供企業建站、網站改版、網站建設、云服務器、品牌網站制作、全網營銷推廣
聲明:本網站發布的內容(圖片、視頻和文字)以用戶投稿、用戶轉載內容為主,如果涉及侵權請盡快告知,我們將會在第一時間刪除。文章觀點不代表本網站立場,如需處理請聯系客服。電話:028-86922220;郵箱:631063699@qq.com。內容未經允許不得轉載,或轉載時需注明來源: 創新互聯