DEV 實現CheckBox單選
阿新 • • 發佈:2018-12-11
廢話不說,直接上程式碼
private void Frm_JHGL_CJMK_MLBW_Load(object sender, EventArgs e) { hs.Clear(); repositoryItemCheckEdit1.CheckedChanged += RepositoryItemCheckEdit1_CheckedChanged; } private void RepositoryItemCheckEdit1_CheckedChanged(object sender, EventArgs e) { CheckEdit pCheckEdit= sender as CheckEdit; if (pCheckEdit.Checked) { MLXXViewModel row = (MLXXViewModel)this.gridView_bwxx.GetRow(this.gridView_bwxx.GetSelectedRows()[0]); var List = grid_MLBWXX.DataSource as MLXXViewModel[]; foreach (var temp in List) {if (條件) { temp.Check = true; hs.Add(CJMK_MLXX); } else { var RemoveData = hs.Where(條件).FirstOrDefault();if (RemoveData != null) { hs.Remove(RemoveData); } temp.Check = false; } } } gridView_bwxx.RefreshData(); }