商国国家互联网信息办公室,机电之家,慧聪网,志趣网哪个好

&四种集合绑定ListView控件和DataGridView控件实现增删改查
秒后自动跳转到登录页
快捷登录:
举报类型:
不规范:上传重复资源
不规范:标题与实际内容不符
不规范:资源无法下载或使用
其他不规范行为
违规:资源涉及侵权
违规:含有危害国家安全等内容
违规:含有反动/色情等内容
违规:广告内容
详细原因:
任何违反下载中心规定的资源,欢迎Down友监督举报,第一举报人可获5-10下载豆奖励。
视频课程推荐
四种集合绑定ListView控件和DataGridView控件实现增删改查
上传时间:
技术分类:
资源评价:
(1位用户参与评价)
已被下载&36&次
四种集合绑定ListView控件和DataGridView控件实现增删改查
本资料共包含以下附件:
四种集合绑定ListView控件和DataGridView控件实现增删改查.rar
51CTO下载中心常见问题:
1.如何获得下载豆?
1)上传资料
2)评论资料
3)每天在首页签到领取
4)购买VIP会员服务,无需下载豆下载资源
5)更多途径:点击此处
2.如何删除自己的资料?
下载资料意味着您已同意遵守以下协议:
1.资料的所有权益归上传用户所有
2.未经权益所有人同意,不得将资料中的内容挪作商业或盈利用途
3.51CTO下载中心仅提供资料交流平台,并不对任何资料负责
4.本站资料中如有侵权或不适当内容,请邮件与我们联系()
5.本站不保证资源的准确性、安全性和完整性, 同时也不承担用户因使用这些资料对自己和他人造成任何形式的伤害或损失
相关专题推荐
还记得童年时候我们经常留恋的这些经
Ruby是一种功能强大的面向对象的脚本
本专题资源是由《深入浅出WPF》作
本专题为您囊括了国外游戏设计与编程
随着网络的发展,各种网站层出不穷,
随着互联网的发展,个人网站层出不穷
Python是一种面向对象、直译式设计语
经常会看到一些比较不错的程序,如何
51CTO开发频道推出《开发月刊》电子杂
本套电子书包含北大青鸟网络教学的全
易语言是一门计算机程序语言。以“易
WPF是基于Vista的用户界面框架,它向
本专题为游戏制作教学视频,视频格式
本专题收集了tangible software solu
本课程针对很少或毫无编程经验的学生
中山大学Delphi面向对象程序设计(采
意见或建议:
联系方式:
您已提交成功!感谢您的宝贵意见,我们会尽快处理DataGridView C#:DataGridView中列类型使用时间控件和下拉列表的自动匹配 - 为程序员服务
为程序员服务
C#:DataGridView中列类型使用时间控件和下拉列表的自动匹配
1. DataGridView中使用时间控件作为列类型
DataGridView中默认不提供DateTimePicker类型的列类型,因此可以通过控件的覆盖模拟所需的功能。详细步骤如下:
第一步,将DataGridView单元格设置为DataGridViewTextBoxColumn类型(文本单元格);
第二步,创建一个DateTimePicker控件dateTimePicker1(时间控件),Visible属性设置为false;
第三步,将时间控件的坐标设置为对应文本单元格的坐标;
第四步,若文本单元格原来为空,则时间控件设置为当前时间,若有值,则时间控件Value属性设置为其值;
第五步,dateTimePicker1的ValueChanged事件和Leave事件的处理。
下面是第三步和第四步的代码:
private void dataGridView1_CellDoubleClick(object sender, DataGridViewCellEventArgs e)
// 设置坐标
this.dateTimePicker1.Left = this.dataGridView1.Left + this.dataGridView1.GetCellDisplayRectangle(e.ColumnIndex, e.RowIndex, false).X;
this.dateTimePicker1.Top = this.dataGridView1.Top + this.dataGridView1.GetCellDisplayRectangle(e.ColumnIndex, e.RowIndex, false).Y;
if (this.dataGridView1.Rows[e.RowIndex].Cells[e.ColumnIndex].Value == null || this.dataGridView1.Rows[e.RowIndex].Cells[e.ColumnIndex].Value.ToString() == &&)
this.dateTimePicker1.Value = DateTime.N
this.dateTimePicker1.Visible =
this.dateTimePicker1.Value = Convert.ToDateTime(this.dataGridView1.Rows[e.RowIndex].Cells[e.ColumnIndex].Value);
this.dateTimePicker1.Visible =
第五步的代码:
private void dateTimePicker1_Leave(object sender, EventArgs e)
this.dateTimePicker1.Visible =
//this.dataGridView1.CurrentCell.Value = this.dateTimePicker1.V
private void dateTimePicker1_ValueChanged(object sender, EventArgs e)
//this.dateTimePicker1.Visible =
this.dataGridView1.CurrentCell.Value = this.dateTimePicker1.V
2. DataGridView中实现DataGridViewComboBoxColumn的自动匹配
这里假定已经设置了DataGridViewComboBoxColumn列的DataSource,则只需在dataGridView的EditingControlShowing事件中添加相关处理逻辑。
// 显示用于编辑单元格的控件时触发
private void dataGridView1_EditingControlShowing(object sender, DataGridViewEditingControlShowingEventArgs e)
if (e.Control.GetType() == typeof(DataGridViewComboBoxEditingControl))
//((ComboBox)e.Control).DropDownStyle = ComboBoxStyle.DropD
ComboBox cbo = e.Control as ComboB
cbo.DropDownStyle = ComboBoxStyle.DropD
cbo.AutoCompleteMode = AutoCompleteMode.SuggestA
// 可能导致绑定多个监听函数,重复执行
//cbo.SelectedValueChanged += new EventHandler(cbo_SelectedValueChanged);
//Console.WriteLine(cbo.SelectedText);
void cbo_SelectedValueChanged(object sender, EventArgs e)
3. DataGridView自动滚动到最新的记录
代码如下:
// 滚动条滚动到最后
if (this.dataGridView1.Rows.Count &= 1)
this.dataGridView1.FirstDisplayedScrollingRowIndex = this.dataGridView1.Rows.Count - 1;
您可能的代码
相关聚客文章
相关专栏文章| 您所在的位置: >
> C# 实时动态刷新列表[如 DataGridView,ListView等C# 实时动态刷新列表[如 DataGridView,ListView等编辑:小乔&&&&来源:转载&&&&更新:&&&&人气:加载中...&&&&字号:|标签:&&&&&&&&&&&&&  ThreadPool.QueueUserWorkItem(_ =&
  this.Invoke((MethodInvoker)(() =&
  lock (m_objLock5)
  if (EVIs.Count != Evss.Count) //出现异常,返回不提取
  foreach (EntityVehicleInfo evi in EVIs)
  int mcuid = evi.MCUID;
  /////////////////////////添加地理位置信息
  EntityVehicleInfo vehicleInfo =
  vehicleInfo = DataReader.Instance.HtVehicleInfo[mcuid]asEntityVehicleI
  if (vehicleInfo == null)
  int Add_InfoIndex = dgvVehicleInfo.Rows.Add(1);
  Row row = dgvVehicleInfo.Rows[Add_InfoIndex];
  dituHelper.GetAddressByGPS(vehicleInfo.Longitude, vehicleInfo.Latitude, Add_InfoIndex);
  row.Cells[&VehicleInfoMCUID&].Value = vehicleInfo.MCUID;
  row.Cells[&VEHICLENO&].Value = vehicleInfo.VehicleNo;
  row.Cells[&ONLINE&].Value = vehicleInfo.O
  row.Cells[&ACC&].Value = vehicleInfo.ACC;
  //row.Cells[&LONGITUDE&].Value = vehicleInfo.Longitude.ToString(&f5&);
  //row.Cells[&LATITUDE&].Value = vehicleInfo.Latitude.ToString(&f5&);
  row.Cells[&ANGLE&].Value =UtilityHelper.Angle2Direction((int)vehicleInfo.Angle);
  row.Cells[&VELOCITY&].Value = vehicleInfo.V
  row.Cells[&LOCATIONSTATE&].Value = vehicleInfo.LocationS
  row.Cells[&RECEIVETIME&].Value = vehicleInfo.ReceiveT
  ////////////////////////////添加状态信息
  EntityVehicleState vehicleState =
  vehicleState = DataReader.Instance.HtVehicleState[mcuid]asEntityVehicleS
  if (vehicleState == null)
  int Add_StateIndex = dgvVehicleState.Rows.Add(1);
  Row row2 = dgvVehicleState.Rows[Add_StateIndex];
  row2.Cells[&VEHICLENOS&].Value = vehicleInfo.VehicleNo.ToString();
  vehicleInfo =
  row2.Cells[&PositionTime&].Value = vehicleState.PositionTime.ToString();
  row2.Cells[&STOPFUEL&].Value = vehicleState.StopFuel ?&是& : &否&;
  row2.Cells[&FUELCUT&].Value = vehicleState.FuelCut ? &断油电& : &通油电&;
  row2.Cells[&AUTODEFENCE&].Value = vehicleState.AutoFence ?&设防& : &解防&;
  row2.Cells[&TRUNKBOOT&].Value = vehicleState.TrunkBoot ?&开启& : &关闭&;
  row2.Cells[&BRAKING&].Value = vehicleState.Braking ? &刹车踩下& : &刹车松开&;
  row2.Cells[&DOOROPEN&].Value = vehicleState.DoorOpen ? &打开& : &关闭&;
  row2.Cells[&ACCON&].Value = vehicleState.ACCOn ? &点火& :&熄火&;
  row2.Cells[&POWERSAVER&].Value = vehicleState.PowerSaver ?&是& : &否&;
  vehicleState =
  catch (Exception ex)
  LogHelper.Writeln(&Instance_NotifyInfo & + ex.StackTrace);
  效果如下:
评论列表(网友评论仅供网友表达个人看法,并不表明本站同意其观点或证实其描述)
分类选择您可能在找这些 上传我的文档
 下载
 收藏
该文档贡献者很忙,什么也没留下。
 下载此文档
正在努力加载中...
c#中DataGridView的基本用法
下载积分:300
内容提示:c#中DataGridView的基本用法
文档格式:PDF|
浏览次数:264|
上传日期: 19:52:18|
文档星级:
全文阅读已结束,如果下载本文需要使用
 300 积分
下载此文档
该用户还上传了这些文档
c#中DataGridView的基本用法
官方公共微信ListView控件和DataGridView控件有什么区别?该如何解决 - C#当前位置:& &&&ListView控件和DataGridView控件有什么区别?该如何ListView控件和DataGridView控件有什么区别?该如何解决&&网友分享于:&&浏览:281次ListView控件和DataGridView控件有什么区别?请师哥师姐讲解额------解决方案--------------------都可以显示一系列的数据。DataGridView通过数据源读取数据库,自带增、删、改、查及排序的功能而ListView的增删改查需要自己手动编写,一般是在需要多种方式显示数据时使用。
------解决方案--------------------同楼上的,。。。。。。
------解决方案--------------------DataGridView 与数据库交互能力比较强.如用在这个控件上实现一些与库交互功能的话可以使用,但效率不是太高ListView 功能相比DataGridView 少一些,但效率高,同进代码量也大.
------解决方案--------------------datafridview 比 listview 功能更强性能listview
------解决方案--------------------从功能上来说,DataGridView强大从性能上来说,ListView比DataGridView好点
------解决方案--------------------DataGridView是以格子显示数据,类似于table。与数据库交互能力比较强.ListView是以列表的形式显示数据。比如:资源管理器右边部分就是ListView来显示的。有图标,信息。可以设置大图标,小图标,详细信息,等。
12345678910
12345678910
12345678910 上一篇:下一篇:文章评论相关解决方案 12345678910 Copyright & &&版权所有

我要回帖

更多关于 中国互联网金融协会 的文章

 

随机推荐