Results 1 to 4 of 4

Thread: [2.0] Selecting only part of a label with BeginEdit

  1. #1

    Thread Starter
    Fanatic Member LITHIA's Avatar
    Join Date
    Dec 2002
    Location
    UK, England
    Posts
    575

    [2.0] Selecting only part of a label with BeginEdit

    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.

  2. #2
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    111,221

    Re: [2.0] Selecting only part of a label with BeginEdit

    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.
    Why is my data not saved to my database? | MSDN Data Walkthroughs
    VBForums Database Development FAQ
    My CodeBank Submissions: VB | C#
    My Blog: Data Among Multiple Forms (3 parts)
    Beginner Tutorials: VB | C# | SQL

  3. #3

    Thread Starter
    Fanatic Member LITHIA's Avatar
    Join Date
    Dec 2002
    Location
    UK, England
    Posts
    575

    Re: [2.0] Selecting only part of a label with BeginEdit

    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.

  4. #4
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    111,221

    Re: [2.0] Selecting only part of a label with BeginEdit

    Quote Originally Posted by LITHIA
    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.
    Why is my data not saved to my database? | MSDN Data Walkthroughs
    VBForums Database Development FAQ
    My CodeBank Submissions: VB | C#
    My Blog: Data Among Multiple Forms (3 parts)
    Beginner Tutorials: VB | C# | SQL

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width