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: ...
随机推荐
- Channel States
Introduction A channel (a call) will go through many different states during its lifetime. Here we w ...
- DedeCMS织梦动态分页类,datalist标签使用实例
<?php require_once(dirname(__FILE__)."/include/common.inc.php");//载入基础文件 require_once(D ...
- KO+bootstrap 模态窗全选绑定
HTML <div id="modalAreaID01"> <button type="button" class="btn btn ...
- Dictionary<TKey, TValue> 类
C# Dictionary<TKey, TValue> 类 Dictionary<TKey, TValue> 泛型类提供了从一组键到一组值的映射.字典中的每个添加项都由一个值及 ...
- 子类实例化和Super
在子类的构造函数当中,必须调用父类的构造函数,通过super的参数个数和类型来决定调用父类哪一个构造函数. class Student extends Person{ Student(){ super ...
- nodejs初探(一)环境搭建,开发工具安装
简介 JavaScript是一种运行在浏览器的脚本,它简单,轻巧,易于编辑,这种脚本通常用于浏览器的前端编程,但是一位开发者Ryan有一天发现这种前端式的脚本语言可以运行在服务器上的时候,一场席卷全球 ...
- angularjs的touch事件
angularJs没有touch事件.这里提供一个touch指令. ngTouch.js "use strict"; angular.module("ngTouch&qu ...
- 相机标定:关于用Levenberg-Marquardt算法在相机标定中应用
LM算法在相机标定的应用共有三处. (1)单目标定或双目标定中,在内参固定的情况下,计算最佳外参.OpenCV中对应的函数为findExtrinsicCameraParams2. (2)单目标定中,在 ...
- ISurfaceOp 接口生成等高线
(1)ISurfaceOp.Contour 根据DEM生成等高线图层: private void button1_Click(object sender, EventArgs e) { ...
- ThinkPHP 3.2.3集成uploadify上传控件
uploadify控件有一个坑爹的问题,就是文件上传时会session丢失,官方解释http://www.uploadify.com/documentation/uploadify/using-ses ...