PDA

Click to See Complete Forum and Search --> : [2.0] Selecting only part of a label with BeginEdit


LITHIA
Nov 25th, 2006, 11:33 AM
Hi everyone.

I have a ListView with lots of items in it that represent files. Their Text properties are the actual filenames for the file that the item represents.

Now, I have allowed the user to edit the name of the file by using the BeginEdit() method. The only problem I have is actually specifying what the part of the text should be selected in the label when it starts to be edited. I would have liked it so that only the name of the file without the extension is selected when I use BeginEdit(), but I have not found anywhere (and I have searched) about specifying what should be selected.

It would be a very easy case of using the LastIndexOf of the text to specify where the text should be selected up to, but I can't find a method/property to just simply specify what part of the label to be selected. At the moment, the entire thing is selected whenever the BeginEdit() is started.

I'm wondering if it can actually be done. I really don't want to have to resort to having to rename the file in order to exploit what is selected. In fact, I see absolutely no methods in which to alter the label that edits it at all.

Thanks very much! I'm rather stuck at this point.

jmcilhinney
Nov 25th, 2006, 06:33 PM
The idea of being able to edit the labels is so that the user can do it through the UI. If you want to make changes yourself then you set the Text property of the item. For that reason there would generally be no reason to do what you ask. You will have to resort to the Windows API to get the window handle of the actual control used to edit the item label and then manipulate it.

LITHIA
Nov 26th, 2006, 04:07 AM
Hm, I didn't want to manipulate the label though, like I said. I only wanted to make it automatically select the name without the extension. That really shouldn't be that hard to do.

Could you direct me to somewhere where I could learn how to do the API for this particular problem? Thanks.

jmcilhinney
Nov 26th, 2006, 05:18 PM
Could you direct me to somewhere where I could learn how to do the API for this particular problem? Thanks.The API forum on this site. Also, gigemboy's signature has links to various useful API tools.