DataGridView鼠标经过Cell时弹出对话框
2013-05-16 09:14
169 查看
Private Sub gdv_view_schedule_MouseMove(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles gdv_view_schedule.MouseMove
Dim hitCell As DataGridView.HitTestInfo = Me.gdv_view_schedule.HitTest(e.X, e.Y)
Dim screenPoint As Point = Me.gdv_view_schedule.PointToScreen(New Point(e.X, e.Y))
Dim row_index As Integer = hitCell.RowIndex
Dim column_index As Integer = hitCell.ColumnIndex
If row_index = -1 OrElse column_index = -1 Then
Return
End If
Dim cell As DataGridViewCell = Me.gdv_view_schedule.Rows(row_index).Cells(column_index)
Dim frist_cell, last_cell, next_cell As DataGridViewCell
Dim start_time, end_time As DateTime
If Not cell.Value Is Convert.DBNull Then
If cell.Value = "Overlap" Then
frist_cell = Me.gdv_view_schedule.Rows(row_index).Cells(0)
last_cell = Me.gdv_view_schedule.Rows(row_index - 1).Cells(column_index)
next_cell = Me.gdv_view_schedule.Rows(row_index + 1).Cells(column_index)
For i As Integer = 0 To Me.end_time.Count - 1
If CType(Me.end_time(i), DateTime).Hour = CType(frist_cell.Value, DateTime).Hour Then
end_time = CType(Me.end_time(i), DateTime)
start_time = CType(Me.start_time(i), DateTime)
End If
Next
If Me.currentCell Is cell Then
Return
End If
If Not Me.currentCell Is cell Then
If (Not Me.hourScheduleViewForm Is Nothing) Then
Me.hourScheduleViewForm.Close()
End If
End If
Me.hourScheduleViewForm = New HourScheduleViewForm()
AddHandler hourScheduleViewForm.ViewFormClosed, AddressOf Me.ViewFormClosed
Me.hourScheduleViewForm.Init(Me.addOnModule, end_time, start_time, last_cell.ToolTipText, cell.ToolTipText, last_cell.Style.BackColor, next_cell.Style.BackColor)
Me.hourScheduleViewForm.Location = screenPoint
Me.hourScheduleViewForm.Show()
'Me.Focus()
Me.currentCell = cell
Else
If (Not Me.hourScheduleViewForm Is Nothing) Then
Me.hourScheduleViewForm.Close()
End If
Me.currentCell = cell
End If
End If
End Sub
备注:HourScheduleViewForm这个窗体使用SplashScreen(初始屏幕)效果会好些,类似于tooltip的效果;同时 Me.hourScheduleViewForm public 变量,主要是为确保每次仅只弹出一个窗体;其中有一部分是用于个人系统的判断代码,不需要时可以直接删除,防止代码冗余
原文:http://blog.csdn.com/wangpeixian/article/details/4348265
Dim hitCell As DataGridView.HitTestInfo = Me.gdv_view_schedule.HitTest(e.X, e.Y)
Dim screenPoint As Point = Me.gdv_view_schedule.PointToScreen(New Point(e.X, e.Y))
Dim row_index As Integer = hitCell.RowIndex
Dim column_index As Integer = hitCell.ColumnIndex
If row_index = -1 OrElse column_index = -1 Then
Return
End If
Dim cell As DataGridViewCell = Me.gdv_view_schedule.Rows(row_index).Cells(column_index)
Dim frist_cell, last_cell, next_cell As DataGridViewCell
Dim start_time, end_time As DateTime
If Not cell.Value Is Convert.DBNull Then
If cell.Value = "Overlap" Then
frist_cell = Me.gdv_view_schedule.Rows(row_index).Cells(0)
last_cell = Me.gdv_view_schedule.Rows(row_index - 1).Cells(column_index)
next_cell = Me.gdv_view_schedule.Rows(row_index + 1).Cells(column_index)
For i As Integer = 0 To Me.end_time.Count - 1
If CType(Me.end_time(i), DateTime).Hour = CType(frist_cell.Value, DateTime).Hour Then
end_time = CType(Me.end_time(i), DateTime)
start_time = CType(Me.start_time(i), DateTime)
End If
Next
If Me.currentCell Is cell Then
Return
End If
If Not Me.currentCell Is cell Then
If (Not Me.hourScheduleViewForm Is Nothing) Then
Me.hourScheduleViewForm.Close()
End If
End If
Me.hourScheduleViewForm = New HourScheduleViewForm()
AddHandler hourScheduleViewForm.ViewFormClosed, AddressOf Me.ViewFormClosed
Me.hourScheduleViewForm.Init(Me.addOnModule, end_time, start_time, last_cell.ToolTipText, cell.ToolTipText, last_cell.Style.BackColor, next_cell.Style.BackColor)
Me.hourScheduleViewForm.Location = screenPoint
Me.hourScheduleViewForm.Show()
'Me.Focus()
Me.currentCell = cell
Else
If (Not Me.hourScheduleViewForm Is Nothing) Then
Me.hourScheduleViewForm.Close()
End If
Me.currentCell = cell
End If
End If
End Sub
备注:HourScheduleViewForm这个窗体使用SplashScreen(初始屏幕)效果会好些,类似于tooltip的效果;同时 Me.hourScheduleViewForm public 变量,主要是为确保每次仅只弹出一个窗体;其中有一部分是用于个人系统的判断代码,不需要时可以直接删除,防止代码冗余
原文:http://blog.csdn.com/wangpeixian/article/details/4348265
相关文章推荐
- DataGridView鼠标经过Cell时弹出对话框
- [ASP.NET]DataGrid鼠标经过感知以及点击行弹出窗口
- js-鼠标经过或点击在鼠标当前位置弹出DIV层
- Jquery利用mouseenter和mouseleave实现鼠标经过弹出层且可以点击
- 鼠标经过某个div时,弹出一个div块
- 鼠标经过弹出透明遮罩层css写法
- JQuery鼠标经过弹出菜单
- 在DataGridView中弹出鼠标右键
- Jquery中国地图热点效果-鼠标经过弹出提示层信息的简单实例
- 在JS中控制从本页面经过action弹出一个对话框
- Discuz!教程之如何隐藏上传附件图片鼠标经过时弹出“下载附件”等信息
- 定义自己的dataGridView实现鼠标经过时高亮显示的效果
- win7 64位系统 开机登录后 黑屏+仅有鼠标 弹出对话框“无法找到脚本文件c:\windows\run.vbs”
- MFC弹出对话框不响应鼠标,只相应回车键的解决方法
- supermap学习系列(五)——上一篇的续集(鼠标单击或者移动,高亮显示并弹出对话框)
- jQuery实现鼠标经过弹出提示信息的地图热点效果
- 实现鼠标点击单元格显示...按钮,点击按钮,弹出对话框,选中后在相应的单元格显示Text,并绑定单元格Value值。
- GridView鼠标经过感知以及点击行弹出窗口
- JavaScript总结之鼠标划过弹出div单击出现对话框
- JS+CSS实现鼠标经过弹出一个DIV框完整实例(带缓冲动画渐变效果)