|
I am attempting my first ever drag and drop: basically I want to drag from a picture to a button (or any other control like a picture or panel) and note the co-ordinates of the point where the drop actually occurs.
The DragEventArgs has properties X and Y which, I understand, are meant to be the co-ordinates where the mouse is when the drop event occurs.
My problem is that, every time I run the same program; drag the same control to the same place the co-ordinates are different!!!
{341,379} {363,408} {385,436} {296,320} {275,291} and so on ......
Can anyone help? Thanks
Deemo
Private Sub PictureBox1_MouseDown(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles PictureBox1.MouseDown<br />
PictureBox1.DoDragDrop(PictureBox1.Name, DragDropEffects.Copy)<br />
<br />
End Sub<br />
<br />
Private Sub button3_DragDrop(ByVal sender As System.Object, ByVal e As System.Windows.Forms.DragEventArgs) Handles Button3.DragDrop<br />
<br />
Dim pt As New Point(e.X, e.Y)<br />
<br />
TextBox3.Text = pt.ToString<br />
End Sub
|
|
|
|
|
You need to know two things for this. The coordinate system of .Net is based upon the container you drop something on. This means if you hit on a button you will get the coordinates relative to its top left corner.
However the drag & drop coordinates are absolute, thus from the top left corner of the desktop. To get the coordinates for the drop you will need to translate them to relative coordinates. You can do this with PointToScreen and PointToClient. If correct this should solve you're problem.
Related documentation:
PointToClient
PointToScreen
|
|
|
|
|
Gerben
Thanks for the references - I will look them up.
What confuses me, however, is that each time I run the same program and click at the same spot (I have drawn a small square on it) I get a different result for the .X and .Y properties - I simply can't understand this
Thanks
Wayne
|
|
|
|
|
I get below C# code :
ControlPaint.DrawCheckBox(graphics, rect, ButtonState.Normal | ButtonState.Flat);
How can i specify it in vb.net.
I got error : Invalid Character if i specify button state as above (ButtonState.Normal | ButtonState.Flat).
any idea? Thanks in advance!
Happy New Year 2006
|
|
|
|
|
merlynml,
Did you try the following?
(graphics, rect, ButtonState.Normal or ButtonState.Flat)
I hope that helps.
Happy New Year.
Mohammed.
For more information, please email me at:
support@cyber-institute.net
|
|
|
|
|
thanks! it's working!
|
|
|
|
|
how to access randomly to the content of spicific folder (the path is known), and getting the name of any file found in this folder (choosed randomly) with spicific type of file.
i didn't find any help in the MSDN????
Militiaware
Faris Madi
-- modified at 19:50 Thursday 29th December, 2005
|
|
|
|
|
here is some msdn help....
msdn[^]
also for more info on files, check the other links for files in the sidebar.
Brian Van Beek
Inside this room, all of my dreams become realities, and some of my realities become dreams. -Willy Wonka
Just started a new blog, yeah! [^]
|
|
|
|
|
i want to enable my program to set picture as desktop wallpaper in different types (center, title, stretch)....
what is the class that give these action..
Militiaware
Faris Madi
|
|
|
|
|
Here are some articles[^], they're in C# though...
Laters!
"..Commit yourself to quality from day one..it's better to do nothing at all than to do something badly.."
-- Mark McCormick || Fold With Us! || Pensieve || VG.Net ||
|
|
|
|
|
When I try to handle MyBase.Click, it is suppose to handle all clicks done on all controls + form right? If not, what to use?
But the problem seems to be that I cannot compare the sender to see what kind of object type I'm dealing with... sender.GetType() seems worthless and something irrelevant, and I have tried different Ifs, like:
If sender Is CType(sender, Panel)
If sender Is Panel
And so on, but it just dont work which is pretty obvious anyways.
Also what if I want to make a Select Case for the sender? How to do this?
I have tried:
Select Case sender
Case Is pnlBack
and different stuffs like that.
Should it be something with CType?
Best Regards,
Hmmkk
|
|
|
|
|
It seems like this works to detect the object type,
Dim ControlType As String
ControlType = Microsoft.VisualBasic.Right(sender.GetType.ToString, Len(sender.GetType.ToString) - (InStr(sender.GetType.ToString, "Forms") + 5))
If ControlType = "Panel" Then
but the problem with handling programmically created controls or all controls still remains...=/ MyBase.Click doesn't work...
Regards,
Hmmkk
|
|
|
|
|
MyBase.Click does NOT handle mouse clicks for the form and everything on it. It only handles the mouse clicks for whatever object MyBase is. There is nothing that handles mouse clicks for the form AND everything on it.
You'd have to specially write the code to attach the Click event for all your controls to the single handler that you're writing. See AddHandler for this. But, this is never recommended. There's actually a performance penalty for routing all the forms controls events through a single Click event handler. It makes for very messy code.
But, there are reasons for do it. For instance, a related group of buttons that all do essentially the same thing could have all their Click events routed to a single Click event handler. See the Handles clause for Event Handlers or the AddHandler and RemoveHandler methods.
Your code for determining object type is grossly convoluted. It works much simpler if you just did:
If TypeOf sender Is object Then
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
My access table has a date field stored as a string. In the select I want to return all records between a beginning and end date on that field. The variables defining starting and ending dates are date type variables.
So I'm trying to convert the table field to a date type in the SQL string. My select is shown below but it does not work when it executes.
The error message is:
"Data type mismatch in criteria expression."
myadapter.SelectCommand = New OleDbCommand("select * from table1 where cdate(ship_date) >= " + date1 + " and cdate(ship_date) <= " + date2, myconnection)
What is wrong?
Thanks for any help provided.
|
|
|
|
|
Are you using a strongly-typed DataSet ? If so, the problem may be with the DataAdapter getting a string when it expects a date for the ship_date column. Try listing the columns explicitly and casting dates appropriately. You should always list columns explicitly, anyway - it's a best practice.
I'm not really sure if this is the problem, tho. Just figured I'd throw it out there to help out.
Michael Flanakin
Web Log
|
|
|
|
|
Hi,
I have made a program that would monitor a directory and watch for file creation using File System Watcher. On the Changed event i basically transfer the file created and copy to another folder using File.Copy. It works fine with small file (less than 1 MB). But for large file the program throws an exception as follows:
System.IO.IOException: The process cannot access the file "D:\VB.Net Testing\dest\Gil Scott-Heron - Blaxploitation.mp3" because it is being used by another process.
where D:\VB.Net Testing\dest\ is the destination folder.
But when if i triggered the copy using something else like Button_Clicked, it just works fine. I guess the problem is with the File System Watcher.
Any way I can get around with this problem? Pls Help.
|
|
|
|
|
chiyinhk wrote: I guess the problem is with the File System Watcher.
No, it's with how your assuming it works.
The Created event fires when the fire is CREATED, not when it's finally full of data and the other app closes it.
Since the other application is still writing to the file, and most probably has an exclusive lock on it, you have to wait until the other process is finished with the file before you can copy it.
To do this, in the Created event, your code has to try to open the file for Exclusive Read (DenyShareAll). If the Open fails, you'll have to wait a couple of seconds, then try again. Keep doing this until the file opens.
When the file finally does open, you can either read the file and copy it yourself, or close the file, then immediately start the File.Copy just like you are now.
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
Hello!
When I locked the access datbase with password, I am not able to open it with the connection string defined below. Any idea why I can't open the
database with the password. I am not typing any wrong password.
When I take out this part (JET OLEDB: Database password=456ffa1;) I am able to process my unlocked database.
Public ConnStr As String = "Provider=Microsoft.jet.OleDB.4.0;Data source=" & Application.StartupPath & "\Database\lyrics.mdb;JET OLEDB: Database password=456ffa1;"
Thanks!
Bedri
|
|
|
|
|
|
I the code i define all the required parameter to connect to a sql server.
Also I define dataset in the code.
i need to bind rows in the dataset to a textbox using textbox binding propertise.
what code i must write in textbox -> properties -> bindingdata -> advance -> text to connect dataset that i define in the code to the textbox.
Thanks....
|
|
|
|
|
after filling the dataset with datatable
write this:
textbox1.text=ctype(dst.tables(0).rows(0).item("ColumnName"),string)
thats all
abhinav
|
|
|
|
|
It's as easy:
TextBox1.DataBindings.Add("Text", myDataSet.Table1, "myField")
vonb
|
|
|
|
|
I have Oracle DB Table with one of its column (VARCHAR). I read and write to
this data [non-english or English] using VC application then everything
works fine. But if I use a VB application to read the data[non-english] and
write it back to the same palce the content is corrupted.
Any help is appreciated
|
|
|
|
|
The problem is solved. It was due to the difference in the way, the Unicode characters are handled by "Oracle Provider for OLE DB" (OraOLEDB.DLL) and "Microsoft OLE DB Provider for Oracle" (msdaora.dll).
Refer : http://support.microsoft.com/kb/q244661/
My vb application was using msdaora.dll while VC++ was using OraOledb.dll !
Suhredayan
|
|
|
|
|
I need create interface in my application program like windows xp.
Pls. Send me *.OCX files to my mail kusal1@gmail.com
Kusal
|
|
|
|