PDA

Click to See Complete Forum and Search --> : [RESOLVED] [2.0] Rename DoubleClick (Delayed DoubleClick)


LITHIA
Oct 4th, 2006, 03:06 PM
Hi everyone,

I was just working on my program and I'm implementing a Rename ability.

At the moment the user has to right click the item and choose rename in order to rename it, but I'd like it so the user can also do a slow double click (like you do in Windows Explorer to rename a file), where you click the the item, wait a second or so and click it again.

I was expecting VS to have this built in as a mouse event, however... I can't see it. All I can see is a normal click and a normal double click.

Does anyone know of this "Delayed Double Click"? I guess it probably isn't built into VS.

If it isn't, I'll be happy to make my own method using a timer (I'll figure something out). I just wanted to make sure there isn't already this method somewhere before I go writing my own. Anyone already written one?

Thanks very much!

jmcilhinney
Oct 4th, 2006, 05:10 PM
There's no such thing as a slow double-click. There are only clicks and double-clicks. Windows Explorer just uses a ListView with its Activation property set to Standard and its LabelEdit property set to True (or at least the unmanaged equivalent to that). Try creating one yourself and you'll see that two single clicks on an item will start editing its label. It's in-built functionality of the ListView. Clicking an item that is not selected will select it, while clicking an item that is selected will start editing it.

LITHIA
Oct 5th, 2006, 04:47 AM
Wow! I never knew about the LabelEdit property. Thanks very much jmcilhinney!

I guess my method that I wrote is obsolete now. I was using some complex code to put a textbox into the label's place, and then using events to re-name the listitem when the textbox's "Leave" event was fired.

Now I feel silly. I wish I knew about the LabelEdit beforehand.

Only one question with this though... Is there a way to manually fire it?

I have the option (on a context menu) to rename the listitem, and I'd like to keep this as an alternative to rename it. Is there a way to fire the LabelEdit?

I was guessing it might have been fired when the listitem was activated, but I didn't see an Activate method to do that manually.

Thanks!

jmcilhinney
Oct 5th, 2006, 06:58 AM
It's important that if you want to do something with a class that you read the help topic for that class and its member listing. When you do that the answer to your question is often obvious.

LITHIA
Oct 5th, 2006, 07:18 AM
It's important that if you want to do something with a class that you read the help topic for that class and its member listing. When you do that the answer to your question is often obvious.

Ok sorry, I had checked the ListViewItem properties and didn't see the BeginEdit. I'm at College and don't have access to the help files, so I quickly checked on MSDN and was searching for LabelEdit. I would probably have found it straight away if I had been at home.

Thanks for the help.