MouseDown not triggered in tablet mode - windows

If my users (who are handicapped children) press their finger on an icon in my application, something should happen right away.
To do that, I react to the MouseDown event.
What I expect is the following:
User touches screen with finger: MouseDown
User releases finger from screen: MouseClick, MouseUp
However, in Windows 10 with Tablet Mode activated, this does not work.
Instead, the sequence "MouseDown", "MouseClick", "MouseUp" is triggered only when the finger is lifted.
How could I make it so that I get a notification about the finger touch?
Sample code in VB.NET:
Public Class Form1
Private Sub Form1_MouseDown(sender As Object, e As MouseEventArgs) Handles Me.MouseDown
Me.ListBox1.Items.Add("mousedown")
End Sub
Private Sub Form1_MouseUp(sender As Object, e As MouseEventArgs) Handles Me.MouseUp
Me.ListBox1.Items.Add("mouseup")
End Sub
Private Sub Form1_MouseClick(sender As Object, e As MouseEventArgs) Handles Me.MouseClick
Me.ListBox1.Items.Add("mouseclick")
End Sub
End Class

Related

Can I hover a graphics object in vb .net (winforms)?

I want to show a tooltip every time I hover a graphics object. I used a bitmap to draw a graphics object in the picture box.
Picturebox does not have a tooltip feature in visual studio, not that i know of anyway. Here is a work around.
imports System.Drawing
Dim varname as new ToolTip()
varname.SetToolTip(PictureBox1, "Tooltip data here")
If you have added the box with WithEvents then use the following code
Private tool As ToolTip = New ToolTip()
Sub OnPictureMouseHover(ByVal sender As Object, ByVal e As EventArgs) Handles PictureBox1.MouseHover
tool.Show("Tooltip", Me)
End Sub
Sub OnPictureMouseLeave(ByVal sender As Object, ByVal e As EventArgs) Handles PictureBox1.MouseLeave
tool.Hide()
End Sub

Scroll Bar Issues Automatically Scrolling Down To The Last Control

Alright, I designed a form to fit onto the current screen size I use, with the form having a vertical scroll bar to view items further down on the form.
At the bottom of the form, I have a couple of checkboxes a user has to select before clicking the submit button.
Once the user hits the submit buttom, the user can't scroll back up to the beginning of the form. The user can scroll back up, but when they stop scroll, it scrolls to the bottom where the last checkbox was checked off.
I assume by checking this last checkbox is that's setting the focus of that control?
Any suggestions on how to fix the scrolling issue?
Keep a note of the last scroll position, and reapply it on Form_Activate
Try this:
'' Declare at form level
Private LastAutoScrollPos As System.Drawing.Point
Private Sub Form1_Activated(sender As Object, e As System.EventArgs) Handles Me.Activated
Me.AutoScrollPosition = LastAutoScrollPos
End Sub
Private Sub Form1_Scroll(sender As Object, e As System.Windows.Forms.ScrollEventArgs) Handles Me.Scroll
If e.ScrollOrientation = ScrollOrientation.VerticalScroll Then
LastAutoScrollPos = New Point(LastAutoScrollPos.X, e.NewValue)
ElseIf e.ScrollOrientation = ScrollOrientation.HorizontalScroll Then
LastAutoScrollPos = New Point(e.NewValue, LastAutoScrollPos.Y)
End If
End Sub

How to suppress the MouseMove event in particular case?

My issue is that I need to change the mouse pointer's position within the MouseMove event, which causes infinite recursion. I need to suppress the MouseMove event which Me.Cursor.Position = newpos generates. How can I do that?
I read about Me.EnableEvents = False but this is not valid for Visual Studio 2005 and I could not find an equivalent.
What exactly are you trying to do? Maybe there's a better way. But assuming this is what you want, you could unsubscribe the event handler in your MouseMove event before changing the cursor position using RemoveHandler. Just add it back when you're done:
Public Class MyForm
Private Sub MyForm_MouseMove(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) _
Handles Me.MouseMove
UnsubscribeEvents()
' change mouse pointer's position here...
ResubscribeEvents()
End Sub
Private Sub UnsubscribeEvents()
RemoveHandler Me.MouseMove, AddressOf MyForm_MouseMove
End Sub
Private Sub ResubscribeEvents()
AddHandler Me.MouseMove, AddressOf MyForm_MouseMove
End Sub
End Class

Copy event handler assignment to another instance

I am trying to create a clone of an object instance.
Creating the new instance and copying property values is no problem but the original object instance has some event handlers assigned to its events. How can I copy event handlers to the new instance?
Thanks..
Here is a code sample...
Public Sub ButtonClick(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button1.Click
MessageBox.Show(sender.Name + "was clicked")
End Sub
Public Sub CloneButton()
Dim newButton = New Button
newButton.Name = Button1.Name + "_Clone"
newButton.Text = Button1.Text
newButton.Width = Button1.Width
newButton.Height = Button1.Height
'Some code here to copy Button1's event handler ButtonClick,
'so when the new button is clicked "Button1_Clone was clicked" is displayed.
End Sub
This is freakin' old, I know, but I can't believe this guy didn't get an answer, it's been answered on SO before, right here.
Just one thing; in the example code given, miHandler will be Nothing if there is no event handler attached to the sourceObject, you should test for that.

ModalPopupExtender + ASP.NET AJAX: Can't page grid

I'm trying to page and sort my DataGrid which is inside a ModalPopupExtender but I can't page it in any way, already tried with <Triggers>, put the UpdatePanel inside, outside, in the middle, and it does NOT work. Modal popup does not get closed but the grid just disappears. Code:
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
If Not Page.IsPostBack Then
BindData()
End If
End Sub
Private Sub btnSearch_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnSearch.Click
SqlServerDS.SelectCommand = "SELECT * FROM emp WHERE name LIKE '%" & txtSearchName.Text & "%'"
BindData()
End Sub
Private Sub BindData()
grdSearch.DataSource = SqlServerDS
grdSearch.DataBind()
End Sub
Private Sub grdBuscaPaciente_PageIndexChanging(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.GridViewPageEventArgs) Handles grdSearch.PageIndexChanging
grdSearch.PageIndex = e.NewPageIndex
BindData()
End Sub
Inside the Designer, this is the code h:
<modalpopupextender>
</modalpopupextender>
<panel>
<updatepanel>
<gridview>
</gridview>
</updatepanel>
</panel>
Tommy is right, so what you just have to do is re-show the popup.
After the BindData() in the PageIndexChanging event show the panel again with the Show() method of the popup extender.
This code is in c# but is pretty much the same.
gvHorarioPB.DataSource = (DataTable)Session["Prueba"];
gvHorarioPB.PageIndex = e.NewPageIndex;
gvHorarioPB.DataBind();
//mpePB is my modalpopupextender
this.mpePB.Show();
If you are using the .NET AJAX toolkit, keep in mind that each time you click someting (paging, sorting, etc.), the page performs a postback, even if it looks AJAX-y. Meaning that you will need to rebind the data each time. Try removing the IfPostback in your page load and see what that does for you.

Resources