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

ASP.NET
asp.net DiscuzNT登录,退出的代码
ASP .NET中执行控件(如ImageButton、LinkButton等)命令不刷新页面
Microsoft SQL Server 2005 Express 远程访问设置详述,100%成功篇
使用.NET命令行编译器编译项目(如ASP.NET、C#等)
asp.net 去除viewstate
asp.net repeater实现批量删除
asp.net安全、实用、简单的大容量存储过程分页
asp.net 获取图片高度和宽度实例代码
在GridView中LinkButton的属性的应用(如何不用选中就删除这一行)
关于.net(C#)中的跨进程访问的问题
asp.net request.PathInfo实现的url重写
asp.net SqlDataReader绑定Repeater
ASP.NET 动态写入服务器端控件
Discuz .net版本中的短消息系统
asp.net动态加载用户控件,关于后台添加、修改的思考
.net Cookies安全性实践分析
配置Visual Studio 以调试.net framework源代码
asp.net 大文件上传 之 改版了的SlickUpload.HttpUploadModule(Krystalware.SlickUpload.dll)
asp.net Web站点风格切换的实现
asp.net 用户控件中图片及样式问题

ASP.NET 中的 C#版MultiSelected DataGrid


出处:互联网   整理: 软晨网(RuanChen.com)   发布: 2009-11-03   浏览: 115 ::
收藏到网摘: 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; } } }}