标签:datagridview style blog color os io
//當主表選擇行更改後,顯示相應的採購資料 private void dgvMain_SelectionChanged(object sender, EventArgs e) { if (this.dgvMain.SelectedRows.Count > 0 && this.dgvItem.DataSource != null && this.dgvItem.Rows.Count > 0) { string fMaterielCode = this.dgvMain.SelectedRows[0].Cells["colMfMaterialCode"].Value.ToString().Trim(); int fSpcId = 0; object oSpcId = this.dgvMain.SelectedRows[0].Cells["colMfSpcId"].Value; if (oSpcId != null && oSpcId.ToString().Length > 0) fSpcId = Convert.ToInt32(oSpcId); //int fSpcId = Convert.ToInt32(this.dgvMain.SelectedRows[0].Cells["colMfSpcId"].Value.ToString().Trim()); CurrencyManager cm = (CurrencyManager)BindingContext[dgvItem.DataSource]; cm.SuspendBinding(); for (int i = 0; i < dgvItem.Rows.Count; i++) { if (dgvItem.Rows[i].Cells["colfMaterielCode"].Value.ToString().Trim().Equals(fMaterielCode) && Convert.ToInt32(dgvItem.Rows[i].Cells["colfSpcId"].Value.ToString()) == fSpcId) { dgvItem.Rows[i].Visible = true; } else { dgvItem.Rows[i].Visible = false; } } cm.ResumeBinding(); } } //显示/隐藏等待框 public void ShowLoading(string strMsg) { if (strMsg.Trim() != "") //顯示 { this.Cursor = Cursors.WaitCursor; lblLoadingMsg.Text = (strMsg.Trim() == "" ? "正在处理中" : strMsg) + ",请稍等..."; pnlLoading.Visible = true; pnlLoading.BringToFront(); Application.DoEvents(); } else //隱藏 { pnlLoading.Visible = false; this.Cursor = Cursors.Default; } }
.Net常用技巧_隐藏/显示DataGridView的行/等待框(转),布布扣,bubuko.com
.Net常用技巧_隐藏/显示DataGridView的行/等待框(转)
标签:datagridview style blog color os io
原文地址:http://www.cnblogs.com/yuyuanfeng/p/3811542.html