Users Pricing

forum

Home Forums How to interact with object in another method using C#? – MindStick

How to interact with object in another method using C#?

Anonymous User 2784 14 Oct 2013

I'm populating a self-made Windows Explorer using TreeView & ListView; and I'm currently working on Creating new Folder. What I want to do is when I press the "New Folder" button, a new listView Item would be added with the name "New folder". After that, let users type in the name of the folder by using BeginEdit() method.

private void buttonNewFolder_Click(object sender, EventArgs e)

        {
            ListViewItem newFolder = listView1.Items.Add("New folder", 1);
            newFolder.BeginEdit();
        }


private void listView1_AfterLabelEdit(object sender, LabelEditEventArgs e)
        {
            Directory.CreateDirectory("C:\"+e.Label); //for example
            // Now how can I change some properties of the "newFolder" listView Item in the above methods (buttonNewFolder_Click) ?
        }

In listView1_AfterLabelEdit method, i use Directory.CreateDirectory("C:\"+e.Label); statement to create a new folder. But now, i want to change some properties of the above "newFolder" ListViewItem (for example Tag, ToolTipItem.. - for another use). How can I interact with that ListView Item in buttonNewFolder_Click method ??? Really really hope you guys can help ! Thanks sooo much in advanced !


1 Answers

Markdown for AI

A clean, structured version of this page for AI assistants and LLMs.

Open .md