473,320 Members | 1,848 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

Drag Drop - KeyState

I want to be able to display a context menu when the user righthand drags an item into a textbox. It states in the documentation that the e.KeyState property will be set accordingly in the drop event. But when I check the value it is always 0, the value is set correctly for Shift, Ctrl, Alt. Am I doing something wrong?

private void textBox2_DragEnter(object sender, System.Windows.Forms.DragEventArgs e)
{
e.Effect = DragDropEffects.Copy;
}

private void textBox1_MouseDown(object sender, System.Windows.Forms.MouseEventArgs e)
{
textBox1.DoDragDrop("Test",DragDropEffects.Copy);
}

private void textBox2_DragDrop(object sender, System.Windows.Forms.DragEventArgs e)
{
label1.Text = e.KeyState.ToString();
}
Nov 16 '05 #1
2 4264
You can probably use the static Control.ModifierKeys property to deterine
what control keys are pressed.

George Shepherd's Windows Forms FAQ contains an entry entitled:

How can I tell if an ALT, Shift or CTL key is pressed without catching
an event?

Check it out at:
http://www.syncfusion.com/faq/winforms/search/656.asp

=============================================
Clay Burch, .NET MVP

Syncfusion, Inc.
visit http://www.syncfusion.com for .NET Essentials

"Paul Ledger" <Pa********@discussions.microsoft.com> wrote in message
news:16**********************************@microsof t.com...
I want to be able to display a context menu when the user righthand drags an item into a textbox. It states in the documentation that the e.KeyState
property will be set accordingly in the drop event. But when I check the
value it is always 0, the value is set correctly for Shift, Ctrl, Alt. Am I
doing something wrong?
private void textBox2_DragEnter(object sender, System.Windows.Forms.DragEventArgs e) {
e.Effect = DragDropEffects.Copy;
}

private void textBox1_MouseDown(object sender, System.Windows.Forms.MouseEventArgs e) {
textBox1.DoDragDrop("Test",DragDropEffects.Copy);
}

private void textBox2_DragDrop(object sender, System.Windows.Forms.DragEventArgs e) {
label1.Text = e.KeyState.ToString();
}

Nov 16 '05 #2
Try this

if(Control.MouseButtons == System.Windows.Forms.MouseButtons.Right)
{
//show context menu
}

--
Shak
(Houston)
"Paul Ledger" <Pa********@discussions.microsoft.com> wrote in message
news:A3**********************************@microsof t.com...
Sorry didnt make it clear in my original post. I want to determine if the right mouse button is down
"ClayB [Syncfusion]" wrote:
You can probably use the static Control.ModifierKeys property to deterine what control keys are pressed.

George Shepherd's Windows Forms FAQ contains an entry entitled:

How can I tell if an ALT, Shift or CTL key is pressed without catching an event?

Check it out at:
http://www.syncfusion.com/faq/winforms/search/656.asp

=============================================
Clay Burch, .NET MVP

Syncfusion, Inc.
visit http://www.syncfusion.com for .NET Essentials

"Paul Ledger" <Pa********@discussions.microsoft.com> wrote in message
news:16**********************************@microsof t.com...
I want to be able to display a context menu when the user righthand
drags an item into a textbox. It states in the documentation that the e.KeyState property will be set accordingly in the drop event. But when I check the
value it is always 0, the value is set correctly for Shift, Ctrl, Alt. Am I doing something wrong?

private void textBox2_DragEnter(object sender,

System.Windows.Forms.DragEventArgs e)
{
e.Effect = DragDropEffects.Copy;
}

private void textBox1_MouseDown(object sender,

System.Windows.Forms.MouseEventArgs e)
{
textBox1.DoDragDrop("Test",DragDropEffects.Copy);
}

private void textBox2_DragDrop(object sender,

System.Windows.Forms.DragEventArgs e)
{
label1.Text = e.KeyState.ToString();
}


Nov 16 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: Lauren Quantrell | last post by:
I'm trying to drop a file from Windows Explorer (or desktop, etc.) onto a field in Access2K and capture the full file path. I found an posting below that says this is possible but I cannot...
2
by: SamSpade | last post by:
There seems to be two ways to put things on the clipboard ( I don't mean different formats): SetClipboardData and OleSetClipboard If I want to get data off the clipboard do I care how it was put...
3
by: Ajay Krishnan Thampi | last post by:
I have a slight problem implementing 'drag and drop' from a datagrid to a tree-view. I have pasted my code below. Someone please advice me on what to do...pretty blur right now. ==code== ...
1
by: Chris | last post by:
Hi, I need to be able to detect when a drag is cancelled after it has started. Meaning: after the drag operation has begun, and the user does not complete the drag, but releases whatever's being...
6
by: jojobar | last post by:
Hello, I look at the asp.net 2.0 web parts tutorial on the asp.net web site. I tried to run it under firefox browser but it did not run. If I want to use this feature in a commercial product...
1
by: Chris Leffer | last post by:
I am trying to run a combination of some MS samples regarding drag and drop. I want to copy or move data from a textbox depending on the Keystate property, but my DragDrop event won't fire: ...
1
by: Manuel Canas | last post by:
Hi there, This is the code that I am using to drag items from a list box and drop them into a text box. I'm not sure, but from what I know, each item on a list box is an object. Let say I get a...
3
by: VB Programmer | last post by:
In VB.NET 2005 (winform) any sample code to drag & drop items between 2 listboxes? Thanks!
5
by: Romulo NF | last post by:
Greetings, I´m back here to show the new version of the drag & drop table columns (original script ). I´ve found some issues with the old script, specially when trying to use 2 tables with...
0
by: DolphinDB | last post by:
The formulas of 101 quantitative trading alphas used by WorldQuant were presented in the paper 101 Formulaic Alphas. However, some formulas are complex, leading to challenges in calculation. Take...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
0
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.