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

ASP.NET
asp.net(c#)网页跳转七种方法小结
完美解决在ModalPopupExtender中使用CalendarExtender时被层遮挡的问题
ASP.NET、SharePoint中另存文件的长文件名被截断的原因及解决办法
查看Json输出的*最方便*的方法 (转)
asp.net 代码隐藏的编码模型
ajaxpro.dll 控件实现异步刷新页面
asp.net DbProviderFactory的使用-示例
一个简单的asp.net 单点登录实现
jQuery+Ajax用户登录功能的实现
asp.net 弹出对话框返回多个值
.NET 中英文混合验证码实现代码
一个完整的ASP.NET 2.0 URL重写方案[翻译]
asp.net关于onpropertychange和oninput事件实现代码
asp.net gridview指定某一列滚动
Equals和==的区别 公共变量和属性的区别小结
asp.net 合并GridView中某列相同信息的行(单元格)
ASP.NET(C#) 定时执行一段代码
asp.net 预防SQL注入攻击之我见
asp.net下将Excel转成XML档的实现代码
asp.net url分页类代码

ASP.NET 中的 C#版MultiSelected DataGrid


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