当前位置: 首页 > 图文教程 > 网络编程 > ASP.NET > .net datagrid 选择多行

ASP.NET
asp+文件上传增强实例
ASP.NET学习手记:验证用户表单输入
关于Microsoft.NET Beta1与Visual Studio.NET Alpha不兼容
asp+ 操作Cookie 方法大全
asp+ 现在已经被官方正式更名为 asp.net
在ASP+ 中我们如何使用 Class 而不是组件
asp+ 如何跨站抓取 页面
在 ASp+ 中的一些可能会用到的 小函数
列出asp+中所有request 的属性和数值
妙用asp+的global.asax
一个asp+ 版本的 Active Server Explorer
asp+中的session 的使用和原理() 不需要cookie也可以使用session
asp.net 的菜单制作(asp.net 的菜单application)
如何在asp+ 中使用自定义的pagelet
如何使用asp+ 动态创建页面元素
用DataGrid分页
给上次的DataGrid分页增加些功能!
asp+ 利用数据绑定来处理XML文件
两种没有使用绑定的 数据显示
asp+中的hash表操作

ASP.NET 中的 .net datagrid 选择多行


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

  功能:点击datagrid并且按住键盘上的ctrl或shift可选择多行

Public Class MyDataGridCLASS
    Inherits DataGrid
    Private m As New ArrayList

    Public ReadOnly Property MultiSelectedIndex() As Integer()
        Get
            Return m.ToArray(GetType(Integer))
        End Get
    End Property

    Protected Overrides Sub OnMouseDown(ByVal e As System.Windows.Forms.MouseEventArgs)
        Debug.WriteLine("DataGrid has hit")
        Dim posdg As Point = New Point(e.X, e.Y)
        Dim hitDG As DataGrid.HitTestInfo = HitTest(posdg)
        If HitDataGrid(hitDG) Then
            MyBase.OnMouseDown(e)
            Debug.WriteLine("Mousedown has gogogo.....")
        End If
    End Sub

    Private Function HitDataGrid(ByVal Hit As DataGrid.HitTestInfo) As Boolean
        Try
            Select Case Me.ModifierKeys
                Case Keys.Control
                    If Hit.Row > -1 Then
                        If m.IndexOf(Hit.Row) > -1 Then
                            m.Remove(Hit.Row)
                            Me.UnSelect(Hit.Row)
                        Else
                            m.Add(Hit.Row)
                            Me.Select(Hit.Row)
                        End If
                    End If
                    Return False
                Case Keys.Shift
                    If Hit.Row > -1 Then
                        For Each IndexOld As Integer In m
                            Me.UnSelect(IndexOld)
                        Next