Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / .NET Framework / General / January 2008

Tip: Looking for answers? Try searching our database.

How to start to edit listview items programatically

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
bz - 30 Jan 2008 09:30 GMT
Hi,

How to start to edit listview items programatically, like in explorer
when user right click on a file the select Rename?

I know how to make items editable with a click, but I want to add a
button / right click menu for this too

Thanks
Jeff Gaines - 30 Jan 2008 09:49 GMT
On 30/01/2008 in message

>I know how to make items editable with a click, but I want to add a
>button / right click menu for this too

I use:

private void DoEditItem()
{
    //    Only handle if 1 item selected
    JLVItemEx lvItem = GetSelectedListViewItem();

    if (lvItem == null)
    {
        FireMessageSender(this, "Please Select One Object To Edit", true);
        return;
    }
    m_EditingLabel = true;
    lvItem.BeginEdit();
}

private JLVItemEx GetSelectedListViewItem()
{
    if (this.SelectedItems.Count != 1)
        return null;

    return (JLVItemEx)this.SelectedItems[0];
}

The key things being to ensure you have a selected ListViewItem and call
lvItem.BeginEdit();
You need to switch JLVItemEx  for ListViewItem if you are using standard
ListViewItems.
Yo need to trap AfterLabelEdit if you want to validate the new text/name.

Signature

Jeff Gaines

bz - 30 Jan 2008 12:58 GMT
Thanks for answer.
It worked for me just by using BeginEdit (that was the method I was
looking for)

I don't understand what is the other code you wrote. What is it good
for? And what is JLVItemEx

Thanks

> On 30/01/2008 in message
>
[quoted text clipped - 35 lines]
> --
> Jeff Gaines
Jeff Gaines - 30 Jan 2008 13:31 GMT
On 30/01/2008 in message
<a8cb0dc1-dc14-4cd1-badc-09815ad7546f@u10g2000prn.googlegroups.com> bz
wrote:

>Thanks for answer.
>It worked for me just by using BeginEdit (that was the method I was
>looking for)
>
>I don't understand what is the other code you wrote. What is it good
>for? And what is JLVItemEx

JLVItemEx is one of my classes based on a ListViewItem, it has additional
properties like Path, FileType etc.
The code is split into small functions in my library and I just copied and
pasted it.
For instance GetSelectedListViewItem() is a function I use all the time so
having it in a function means I just have to call the function and know I
will either get a valid ListViewItem or null returned, it saves a lot of
repetitive code.
The same with DoEditItem() - it can be called from a menu, the F2 key or
even from outside the file it is in.

Signature

Jeff Gaines

bz - 30 Jan 2008 14:01 GMT
> On 30/01/2008 in message
> <a8cb0dc1-dc14-4cd1-badc-09815ad75...@u10g2000prn.googlegroups.com> bz
[quoted text clipped - 9 lines]
> JLVItemEx is one of my classes based on a ListViewItem, it has additional
> properties like Path, FileType etc.

Thanks, I thought it was some NET class I wasn't aware of.

Regards
Bogdan

> The code is split into small functions in my library and I just copied and
> pasted it.
[quoted text clipped - 7 lines]
> --
> Jeff Gaines

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.