| | |
Problem on dragging
Please support our VB.NET advertiser: Intel Parallel Studio Home
Thread Solved |
•
•
Join Date: Jul 2009
Posts: 47
Reputation:
Solved Threads: 0
Hi
I have problem on dragging label
when the application show msgbox , it stop responding
I do n't know what is problem in my code :
I have problem on dragging label
when the application show msgbox , it stop responding
I do n't know what is problem in my code :
vb .net Syntax (Toggle Plain Text)
dim l1 as label Dim serverindex, serverP As Integer Dim serverref As String Dim copiedFragment As String Private Sub Form3_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load l1=new label() l1.text="string" AddHandler l1.MouseDown, AddressOf labelmouse_down AddHandler l1.MouseMove, AddressOf labelmove AddHandler Label11.DragEnter, AddressOf enter_server End Sub Sub enter_server( _ ByVal sender As System.Object, _ ByVal e As System.Windows.Forms.DragEventArgs) Dim len As Integer = draggedlabel.IndexOf(":") draggedlabel = draggedlabel.Substring(0, len) serverP = serverindex serverref = sender.text If e.Data.GetDataPresent(DataFormats.Text) Then paste(len, draggedlabel, True) ' move variable If MsgBox("Do yo want to move " & draggedlabel & _ " from " & vbCrLf & server_names(serverP), MsgBoxStyle.YesNo) = MsgBoxResult.Yes Then e.Effect = DragDropEffects.Copy paste(len, draggedlabel, True) Else e.Effect = DragDropEffects.Move paste(len, draggedlabel, False) End If Else e.Effect = DragDropEffects.None End If end sub Sub labelmouse_down( _ ByVal sender As System.Object, _ ByVal e As System.Windows.Forms.MouseEventArgs) If (e.Button.Left) Then mouse = True ' MsgBox(sender.text) End If End Sub Sub labelmove( _ ByVal sender As System.Object, _ ByVal e As System.Windows.Forms.MouseEventArgs) If mouse = True Then sender.DoDragDrop(sender.text, DragDropEffects.Copy Or DragDropEffects.Move) End If draggedlabel = sender.text ' RemoveHandler Label1.MouseUp, AddressOf mouse_up mouse = False End Sub Sub paste(ByVal len As Integer, ByVal copied_fragment As String, ByVal cut As Boolean) msgbox(len.tostring & copied_fragment ) End Sub
Here's a few things to fix first:
- add
- line 19: you refer to draggedlabel but you haven't declared it. Is it a label control in the form?
- line 22: sender is of type Object which does not have Text property and thus
- line 44: should be
- lines 57 and 60: cast sender object to correct type, like
Simply fixing these type issues may solve your problem. I don't remember seeing an app that prompts a message box at DragEnter event but without actually testing it, I don't see any reason why it shouldn't work. In general I would personally take away that confirmation. If the user has an opportunity to drag&drop something, he/she usually knows what he/she is doing
HTH
- add
Option Strict On and Option Explicit On lines at the beginning of vb-file- line 19: you refer to draggedlabel but you haven't declared it. Is it a label control in the form?
- line 22: sender is of type Object which does not have Text property and thus
serverref = sender.text does not work. You have to cast sender to correct type first. If it's a label, use serverref = CType(sender, Label).Text - line 44: should be
If e.Button = Windows.Forms.MouseButtons.Left Then - lines 57 and 60: cast sender object to correct type, like
CType(sender, Label) Simply fixing these type issues may solve your problem. I don't remember seeing an app that prompts a message box at DragEnter event but without actually testing it, I don't see any reason why it shouldn't work. In general I would personally take away that confirmation. If the user has an opportunity to drag&drop something, he/she usually knows what he/she is doing

HTH
Last edited by Teme64; Aug 1st, 2009 at 6:35 am. Reason: Pressed submit by mistake :)
Teme64 @ Windows Developer Blog
•
•
Join Date: Jul 2009
Posts: 47
Reputation:
Solved Threads: 0
Teme64
thanks..
I declare draggedlabel a0s string
ther I havn't broblem , this statment works
maebe your away to get text of label better , thanks
I removed msg boxes from dragEnterEvent , so , I put it in DragDrop event .
the dragged label must enter both event dragEnter and DragDrop ..
It's now work Properly
thanks..
•
•
•
•
line 19: you refer to draggedlabel but you haven't declared it. Is it a label control in the form?
•
•
•
•
serverref = sender.text does not work
maebe your away to get text of label better , thanks
I removed msg boxes from dragEnterEvent , so , I put it in DragDrop event .
the dragged label must enter both event dragEnter and DragDrop ..
It's now work Properly
![]() |
Similar Threads
- dragging in mozilla... (JavaScript / DHTML / AJAX)
- Problem Loading Movieclips from library (Graphics and Multimedia)
- Rounded corners - one more time (Pascal and Delphi)
- XML Atom feed IE6 and Firefox vs. IE7 problem (RSS, Web Services and SOAP)
- Small problem face me (C#)
- Strange problem with router (Networking Hardware Configuration)
- Power Supply Problem? Help Please (Cases, Fans and Power Supplies)
- Pointer to function as an argument (C++)
- Help viewer problem (OS X)
Other Threads in the VB.NET Forum
- Previous Thread: Data updated Problem
- Next Thread: Call a button click event under another sub procedure
| Thread Tools | Search this Thread |
.net .net2008 2008 access account advanced application array basic beginner browser button buttons center click code combo cuesent data database datagrid datagridview date datetimepicker designer dissertation dissertations dissertationtopic excel exists fade filter forms ftp generatetags html images input insert intel internet listview map mobile module monitor msaccess net number objects open panel passingparameters pdf picturebox picturebox2 port position print printing problem regex right-to-left save search searchvb.net select serial settings shutdown socket sqldatbase sqlserver survey table temperature textbox timer timespan transparency txttoxmlconverter update user usercontol vb vb.net vb.netformclosing()eventpictureboxmessagebox vba vbnet visual visualbasic visualbasic.net visualstudio.net visualstudio2008 web winforms wpf wrapingcode xml year





