当前位置:首页 > Windows程序 > 正文

KeyPressEventArgs e){ if (e.KeyChar != 8 !Char.IsDigit(e.Ke

2024-03-31 Windows程序

//注册绑定事件 private void dgvBidFile_EditingControlShowing(object sender, DataGridViewEditingControlShowingEventArgs e) { DataGridView dataGridView = (DataGridView)sender; int columnIndex = dataGridView.CurrentCell.ColumnIndex; if (columnIndex == 3||columnIndex==5||columnIndex==6) { e.Control.KeyPress += new KeyPressEventHandler(TextBoxDec_KeyPress); } if (dataGridView.CurrentCell.GetType().Name == "DataGridViewComboBoxCell") { bidFileId = Convert.ToInt32(dataGridView.CurrentRow.Cells[this.colBidFileId.Index].Value); ComboBox comboBox = (ComboBox)e.Control; comboBox.SelectedIndexChanged += new EventHandler(this.comboBox_SelectedIndexChanged); } } //只输入数字判定事件。该事件是手动添加的绑定事件 private void TextBoxDec_KeyPress(object sender, KeyPressEventArgs e) { if (e.KeyChar != 8 && !Char.IsDigit(e.KeyChar) && e.KeyChar != .) { e.Handled = true; } } //下拉框变动事件,,该事件是手动添加的绑定事件 private void comboBox_SelectedIndexChanged(object sender, EventArgs e) { ComboBox comboBox = (ComboBox)sender; //接下来获取下来框中的内容... //comboBox.Text为当前选定的下拉框的内容 } //普通文本框变动事件 private void dgvBidFile_CellValueChanged(object sender, DataGridViewCellEventArgs e) { if (e.ColumnIndex == this.colRemark.Index) { //colRemark为数据绑定列 //产生什么事... } }

温馨提示: 本文由Jm博客推荐,转载请保留链接: https://www.jmwww.net/file/35013.html

Jm-杰米博客Jamie
草根站长的技术交流乐园!IT不会不要紧快来好好学习吧!
  • 20786文章总数
  • 7494590访问次数
  • 建站天数
  • 友情链接