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

ASP.NET
关于数据绑定在Web页面呈现效果的一点小技巧
菜鸟模仿duwamish开发时常见的错误
基于.net的快速开发思想
ASP.Net实现将Word转换PDF格式
用ASP.NET建立一个在线RSS新闻聚合器
ASP.NET图象处理详解
名称地址(Namespace)
Win中Net命令的另类用法
浅析.Net下的多线程编程
构造.NET环境下的网页下载器 (1)
构造.NET环境下的网页下载器 (2)
ASP.NET编程中的十大技巧(上)
ASP.NET编程中的十大技巧(下)
C# 3.0语言详解之基本的语言增强
Windows.NET Server: XML Web 服务
ASP.Net中程序构架与程序代码的分离
.NET 数据访问架构指南
用Visual C#打造多页面网页浏览器
.NET 2.0 基础类库中的范型:范型集合
.NETCompactFramework的使用技巧

ASP.NET 中的 C#版MultiSelected DataGrid


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