DataGridView的DataGridViewComboBoxColumn列在编辑时自动弹出下拉列表
在DataGridView的CellEnter的事件中添加如下代码即可:
if (e.ColumnIndex == dataGridView1.Columns["仓库名"].Index) {
dataGridView1.BeginEdit(false);
System.Windows.Forms.ComboBox c = dataGridView1.EditingControl as System.Windows.Forms.ComboBox;
if (c != null) {
c.DroppedDown = true;
} }
思路参考来源:https://social.msdn.microsoft.com/Forums/windows/en-US/27b08305-e7ce-4d4d-b608-c544e2748a81/datagridviewcomboboxcell-making-it-drop-down-automatically?forum=winformsdatacontrols
private void dataGridView1_EditingControlShowing(object sender, DataGridViewEditingControlShowingEventArgs e) {
if (dataGridView1.CurrentCell.OwningColumn is DataGridViewComboBoxColumn)
{
System.Windows.Forms.ComboBox combo = (System.Windows.Forms.ComboBox)e.Control;
combo.KeyDown += new KeyEventHandler(combo_KeyDown);
}
} void combo_KeyDown(object sender, KeyEventArgs e) {
System.Windows.Forms.ComboBox c = sender as System.Windows.Forms.ComboBox;
if (c != null) {
c.DroppedDown = true;
}
}
DataGridView的DataGridViewComboBoxColumn列在编辑时自动弹出下拉列表的更多相关文章
- DataGridView的DataGridViewComboBoxColumn列点击一次,自动处于编辑状态
本文转载:http://www.cnblogs.com/Johnny_Z/archive/2012/02/12/2348235.html Winform中的DataGridView数据绑定控件有时会用 ...
- Android打开某个activity时自动弹出输入法键盘
最近在做一个可以让用户修改自己账户资料的activity,具体是打开后有一个EditText,然后用户可以在这里输入相关信息,但是做好后发现,进入这个activity时系统并没有自动弹出输入法键盘,于 ...
- 屏蔽按CapsLock键切换到大写时,编辑框自动弹出的提示(UnregisterClass(TOOLTIPS_CLASS)后,重新设置WndProc并注意返回值)
WNDPROC OldProc; LPCTSTR lpStr = TEXT("保持大写锁定打开可能会使您错误输入密码"); LRESULT CALLBACK WindowProc( ...
- PL/SQL Developer去掉启动时自动弹出的Logon弹出框方法
以前用PL/SQL Developer 7.0版本,最近升级到PL/SQL Developer 11.0版本,但每次启动PL/SQL Developer都会自动弹出Logon窗口,并且选中其中的登录历 ...
- jquery UI autocomplete当输入框焦点聚焦时自动弹出跟随下拉框
$("#search").autocomplete({ minLength: 0, source: function(request,response){ // request对象 ...
- [Winform] DataGridView 中 DataGridViewComboBox 的可编辑
在 DataGridView 中设置的 DataGridViewComboBox,默认是不可编辑的,即使将其列属性 DisplayStyle 设置成 ComboBox 或其他,也无法编辑: 故作如下处 ...
- DataGridView中DataGridViewComboBoxColumn的一些相关应用(一)让其值改变时触发事件-转
转自 https://maodaili.de/mao.php?u=a%2FMrbEvUE8PnCuc7FrhJi0Rqd3kmOBHPZUbcJ1c2hbJUK0RYWpAf4lhIOddItP%2 ...
- Winform 中DataGridView的checkbox列,当修改checkbox状态时实时获得其状态值
不知道大家有没有这样的经验,当点击或者取消datagridview的checkbox列时,比较难获得其状态是选中还是未选中,进而不好进行其它操作,下面就列出它的解决办法: 主要用到了DataGridV ...
- jqgrid 让隐藏的列在编辑状态时出现且可编辑
有时,我们需要隐藏一个列数据,但在启动编辑时又能够被编辑. 1.设置列为编辑:editable: true 2.设置 editrules属性值为: edithidden: true colModel: ...
随机推荐
- 论文笔记之:Progressive Neural Network Google DeepMind
Progressive Neural Network Google DeepMind 摘要:学习去解决任务的复杂序列 --- 结合 transfer (迁移),并且避免 catastrophic f ...
- (转)分布式深度学习系统构建 简介 Distributed Deep Learning
HOME ABOUT CONTACT SUBSCRIBE VIA RSS DEEP LEARNING FOR ENTERPRISE Distributed Deep Learning, Part ...
- 论文笔记之:A CNN Cascade for Landmark Guided Semantic Part Segmentation
A CNN Cascade for Landmark Guided Semantic Part Segmentation ECCV 2016 摘要:本文提出了一种 CNN cascade (CNN ...
- MSSQL反旋转的例子
with cte as ( select 'A' as tag , as num_1 , as num_2 , as num_3 , as num_4 ,null as num_5 union sel ...
- 利用 Excel 公式进行数据整理
一个考勤机里导出来的数据明细: A3公式:=IF(MOD(ROW(Sheet1!U5),2)=1,Sheet1!U5,INDIRECT("Sheet1!U"&ROW(She ...
- 【MySQL】探究之null与not null
相信很多用了mysql很久的人,对这两个字段属性的概念还不是很清楚,一般会有以下疑问: 我字段类型是not null,为什么我可以插入空值 为毛not null的效率比null高 判断字段不为空的时候 ...
- UNIX网络编程-基本API介绍(二)
参考链接:http://www.cnblogs.com/riky/archive/2006/11/24/570713.aspx 1.getsockname和getpeername getsocknam ...
- 使用nginx部署Yii 2.0\yii-basic-app-2.0.5
nginx.conf #user nobody;worker_processes 1; #error_log logs/error.log;#error_log logs/error.log noti ...
- IIS7 IIS7.5 IIS8.5 HTTP 错误 500.19 – Internal Server Error解决方案小记
今天配置IIS(win8.1 IIS8.5)的web.config出现如下错误: HTTP 错误 500.19 – Internal Server Error无法访问请求的页面,因为该页的相关配置数据 ...
- SQLite数据库文件格式
数据库命名约定 sqlite3_open()API用到数据库的文件名,可以是相对当前工作目录的相对路径名,也可以是从系统根文件树开始的完整路径名.任何被本地文件系统接受的正规文件名都是好的. 如果文件 ...