当前位置: 首页 > 图文教程 > 网络编程 > ASP.NET > C#版MultiSelected DataGrid

ASP.NET
简单Web service 身份验证解决方案
asp.net SQL存储过程分页
asp.net 虚拟主机时常出现MAC验证失败错误之解决方法
ASP.net(c#) 生成html的几种解决方案[思路]
asp.net 生成静态页时的进度条显示
asp.net Coolite 学习交流
Coolite Cool Study 1 在Grid中用ComboBox 来编辑数据
Coolite Cool Study 2 同时更新多个Tab
Coolite Cool Study 3 MVC + Coolite 的实现代码
CommunityServer又称CS论坛的相关学习资料
C# 给站点指定位置的某种格式的图片添加水印
C# 添加文字水印类代码
asp.net 纯真ip库取得所在地实现代码
.NET 动态编译
C# 动态编译、动态执行、动态调试
asp.net 实现自定义Hashtable (.net)
asp.net 2.0的文件上传(突破上传限制4M)
C# OWC生成图表
asp.net javascript 文件无刷新上传实例代码
ASP.net 路径问题 详细说明

ASP.NET 中的 C#版MultiSelected DataGrid


出处:互联网   整理: 软晨网(RuanChen.com)   发布: 2009-11-03   浏览: 109 ::
收藏到网摘: n/a

using System;using System.Drawing;using System.Collections;using System.Windows.Forms;namespace cSharpDataGrid{ public class MyDataGrid : System.Windows.Forms.DataGrid { private ArrayList m=new ArrayList(); Array MultiSelectedIndex { get { return this.m.ToArray(typeof (int)); } } protected override void OnMouseDown(System.Windows.Forms.MouseEventArgs e) { Console.WriteLine("Datagrid has hit"); Point _posDg = new Point(e.X,e.Y); System.Windows.Forms.DataGrid.HitTestInfo _hitDg =base.HitTest(_posDg); if (HitDataGrid(_hitDg)) { base.OnMouseDown(e); } base.OnMouseDown (e); } private bool HitDataGrid(DataGrid.HitTestInfo Hit) { try { switch (MyDataGrid.ModifierKeys) { case Keys.Control: if (Hit.Row>-1) { if (m.IndexOf(Hit.Row)>-1) { m.Remove(Hit.Row); this.UnSelect(Hit.Row); } else { m.Add(Hit.Row); this.Select(Hit.Row); } } return false; case Keys.Shift: if (Hit.Row>-1) { foreach (int intIndex in m) { this.UnSelect(intIndex); } m.Clear(); int _count; int _intStep; if (Hit.Row>this.CurrentRowIndex) { _intStep=1; } else { _intStep=-1; } for (_count=this.CurrentRowIndex ;_count==Hit.Row;_count+=_intStep) { m.Add(_count); this.Select(_count); } } return false; default: foreach (int _intIndex in m) { this.UnSelect(_intIndex); } m.Clear(); if (Hit.Type==DataGrid.HitTestType.RowHeader) { m.Add(Hit.Row); } return true; } } catch(System.Exception ex) { throw ex; } } }}