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

ASP.NET
.Net基础:在ASP.net中网站访问量统计方法
Asp.Net 建立一个在线 RSS 新闻聚合器
ASP.NET从字符串中查找字符出现次数的方法
了解ASP.NET中的IFRAME框架挂马
JAVA和.NET两个平台对于安全功能的比较
.NET中*延迟*特性的几个陷阱
使用ASP.NET Global.asax 文件
在.NET环境下为网站增加IP过滤功能
如何实现.net程序的进程注入
在.Net Micro Framework中显示汉字
引以为戒 .NET开发者常犯的错误
WinForm程序中使用控制台作为输出窗口
浅谈如何使用 Lambda 表达式做抽象代表
.Net基础:C#中对DatagridView部分常用操作
ASP.NET LinkButton组件编程浅析
ASP.NET中使用AJAX中的方式
ASP.NET组件设计之生命周期详解
asp.net下web控件点评
.Net应用:ASP.NET中使用AJAX中的方式
.Net基础:ASP.NET中的javascript操作

ASP.NET 中的 C#版MultiSelected DataGrid


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