|
I have several labels on a panel that I am using the MouseDown event to start drag and drop processes. this is fine, but I also need to have a DoubleClick event on the labels. the problem is that the mousedown event prevents the doubleclick from firing. The double click is an overloaded panel DoubleClick event. Something like this:
private void lbItems_MouseDown(object sender, MouseEventArgs e)
{
lbItems.DoDragDrop(lbItems.Items[lbItems.SelectedIndex].ToString(), DragDropEffects.Copy | DragDropEffects.Move);
}
private void pnlImageBorder_DragEnter(object sender, DragEventArgs e)
{
e.Effect = DragDropEffects.Move;
}
private void pnlImageBorder_DragDrop(object sender, DragEventArgs e)
{
if (e.Data.GetDataPresent(typeof(Label)))
{
Label label = (Label)e.Data.GetData(typeof(Label));
label.Location = pnlImageBorder.PointToClient(new Point(e.X, e.Y));
}
else
{
Point locPoint = pnlImageBorder.PointToClient(new Point(e.X, e.Y));
placeLabel(locPoint);
}
}
void Form1_MouseDown(object sender, MouseEventArgs e)
{
if (sender is Label)
{
Label label = (Label)sender;
pnlImageBorder.DoDragDrop(label, DragDropEffects.Move);
}
}
private void pnlImageBorder_DragOver(object sender, DragEventArgs e)
{
if (e.Data.GetDataPresent(typeof(Label)))
{
Label label = (Label)e.Data.GetData(typeof(Label));
label.Location = pnlImageBorder.PointToClient(new Point(e.X, e.Y));
}
}
private void pnlImageBorder_Paint(object sender, PaintEventArgs e)
{
DoPage(e.Graphics, ForeColor, pnlImageBorder.ClientSize.Width, pnlImageBorder.ClientSize.Height);
base.OnPaint(e);
}
protected void pnlImageBorder_DoubleClick(object sender, EventArgs e)
{
if (sender is Label)
{
MessageBox.Show("label");
}
else
{
MessageBox.Show("not label");
}
}
So as you can imagine mousedown event superceeds the double click.
Thanks in advance
cbeasle1
|
|
|
|
|
Don't start a drag and drop sequence (via DoDragDrop) until the user has mouse down and has moved the mouse position a certain number of pixels in either direction.
Tech, life, family, faith: Give me a visit.
I'm currently blogging about: How 'bout a little guitar now?
The apostle Paul, modernly speaking: Epistles of Paul
Judah Himango
|
|
|
|
|
How can I get the number of pixils the mouse has moved? The only thing I have found relative to this is SystemInformation.DragSize, but I do not think that is exactly it. I am assuming you mean that I should have a drag distance conditional inside the mousedown event before calling the DoDragDrop call.
Thanks again.
cbeasle1
|
|
|
|
|
DragSize is the constant value maintained by the operating system indicating how many pixels the mouse must move before it is considered a drag operation.
Set a flag in your mouse down event that the mouse is down, and log the location of the mouse. Inside the MouseMove event, check and see if the mouse is still down. If it is, compare its position to the original mouse down location. If that distance between the current mouse location and the original mouse down location constitutes a move, then you can call DoDragDrop.
|
|
|
|
|
hi every body
we can use very simple way for soulution:by(e.Clicks = 1)
Private Sub pbBook_MouseDown(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles pbBook.MouseDown
If e.Button = Windows.Forms.MouseButtons.Left AndAlso e.Clicks = 1 then
Me.DoDragDrop(str, DragDropEffects.Copy)
End If
|
|
|
|
|
Hi.
I am wondering how one goes about letting a user of a Windows forms app select a certain file at a certain location and then the application does whatever with the file.
What I am refering to is similar to what we see when we are attaching files in an email, one presses a button and then a dialog box opens that enables the user to browse to a certain location and select a file that is then attached to the email. I would like to know how one can get the app to work with the file chosen by the user at some location on his/her computer?
Thanks,
F
|
|
|
|
|
Look into the OpenFileDialog class on MSDN.
When you call the ShowDialog function, a browse dialog appears. You can set filters, default directory, ...
Hope this helps.
Coulda, woulda, shoulda doesn't matter if you don't.
|
|
|
|
|
OpenFileDialog - its in the components of Visual Studio.
|
|
|
|
|
Hi.
I am wondering how one goes about letting a user of a Windows forms app select a certain file at a certain location and then the application does whatever with the file.
What I am refering to is similar to what we see when we are attaching files in an email, one presses a button and then a dialog box opens that enables the user to browse to a certain location and select a file that is then attached to the email. I would like to know how one can get the app to work with the file chosen by the user a some location on his/her computer?
Thanks,
F
|
|
|
|
|
If you look here:
System.Windows.Forms.FileDialog
System.Windows.Forms.FolderBrowserDialog
You will get what you want.
Ant.
I'm hard, yet soft. I'm coloured, yet clear. I'm fruity and sweet. I'm jelly, what am I? Muse on it further, I shall return! - David Walliams (Little Britain)
|
|
|
|
|
Actually,
I found one article on this in codeproject,but that source giving some probem at getRegistryHandle function.Please update me how can i solve that.
|
|
|
|
|
Hi,
I'm writing a web service with C#. I'm using VS.NET 2005 but I can't understand the way VS.NET create a web service (EX: I can't find the .wsdl file).
Can you explain it?
Thanks,
Hung.
Hung
|
|
|
|
|
|
Hi,
I am working on a web application in ASP.net & C# .For one of the utilities on my site, i need to use an available VC++ project.
This VC++ project produces an exe as its output.
I tried changing the output type of the VC++ project to .dll, but it doesn't help and after this, the project itself stops working.
Can someone please tell me as to how to use this VC++ project into my web application?
Thanks.
|
|
|
|
|
There're some very big issues involved here. If your VC++ project produces an exe, it is either a Windows or Console application project. So look bellow. This would work with VS2008, I don't remember how to do it using older versions.
1.- [Easiest] Is the VC++ project a managed project? Go to project properties and take a look under "Common Properties", if this tab works. Allows you to change "Targeted Framework", add references or so. It is a managed project. Solution: Just changed your project output type: Go to "Configuration Properties" > "General" > "Configuration Type" and change it to "Dynamic Library (.dll)". And just try placing the reference in your web.config, it should work. Down side. Global funcions and not managed types are not going to work for you ASP.NET site. All types you'd like to use must be marked as "__gc" or "__value". Take a look to this MSDN link > ms-help://MS.VSCC.v90/MS.MSDNQTR.v90.en/dv_vclang/html/63b1e7ab-d1c8-4582-aa89-21bfddf694a9.htm
2.- [Hardest] Your project is a native one. Solution: First, change the project type, same as above (not mandatory, exe also can export functions). You'll have to make sure you're exporting the funcions you'd like to use from managed code. To see exported functions use "dumpbin.exe /EXPORTS <exe or="" dll="" file="">" from VS command prompt. Then you'll have to create a "wrapper" managed library to access to unmanaged, see this one to use native functions from managed code > ms-help://MS.VSCC.v90/MS.MSDNQTR.v90.en/fxref_mscorlib/html/36830e35-7f2e-b1fa-87ca-144346051059.htm . Down side, most web hostings won't allow you to access to native code, or at lest no more than .NET native libraries or Windows API.
Hope it'll help
|
|
|
|
|
Hi
how can i check whether a screen saver is running or not.
Shajeel
|
|
|
|
|
tip #1: use google :>
tip #2: http://www.neowin.net/forum/lofiversion/index.php/t298659.html
|
|
|
|
|
Distortation/flickering occur while Open one form & Close another in c#(Windows)
On some Event(e.g Button Click) on Form1
Form2 f=new Form2(ref newDataSet);
f.show();
Form1.close();
i'm also passing some DataSet,Variable to the constructor of Form2
Sushil
-- modified at 5:41 Wednesday 5th April, 2006
|
|
|
|
|
hi everyone,
Here is my question:
In a WebForm we have taken two dropdownlists say dropdownlist1 and dropdownlist2.In the drop down list1 there is(jpeg image,textdocument) attached to it.
We have taken one folder(folder name temp) on the desktop.This folder contains(jpeg image1,textdocument1,jpegimage2,textdocument2 ).
now my question is on the dropdownlist1 when i click on jpegimage the file which is there on the desktop those two jpeg images i.e,image1 and image2 should be displayed on the dropdownlist2.
plz give me code for this program
thanku,
byeee
murali
|
|
|
|
|
Do your own homework
Ed
|
|
|
|
|
http://www.parashift.com/c++-faq-lite/how-to-post.html#faq-5.2
|
|
|
|
|
I have a standard C library file : "abc.dll". Now I want to reuse it with C# (VS.NET 2005). How can I do this?
Thanks,
Hung.
Hung
|
|
|
|
|
|
You must use InteropServices...
<br />
using System.Runtime.InteropServices<br />
then DllImport attribute
<br />
[DllImport("User32.dll")]<br />
public static extern int MessageBox(int h, string m, string c, int type);<br />
Then you are avaible to use MessageBox function
all code will be locking such the following:
<br />
using System;<br />
using System.Runtime.InteropServices;<br />
class MainClass <br />
{<br />
[DllImport("User32.dll")]<br />
public static extern int MessageBox(int h, string m, string c, int type);<br />
<br />
static int Main() <br />
{<br />
string myString; <br />
Console.Write("Enter your message: ");<br />
myString = Console.ReadLine();<br />
return MessageBox(0, myString, "My Message Box", 0);<br />
}<br />
}<br />
|
|
|
|
|
Thanks!
But my "abc.dll" file is not registered in Windows, and I don't want to register it! Do you have other ideas?
Hung
|
|
|
|