Solved

Automaticly select the row that has been created in a listview.

Posted on 2011-09-28
5
180 Views
Last Modified: 2013-12-17
Hi,

I have a methode to create a row in a listview and it works perfect.
But now I would like when a row is created in the listview it must
be selected too.

Who knows the answer and is willing to help me?

Greetings,

Peter
private void tbNewNote_Click(object sender, EventArgs e)
        {
            frmNote.lblTitle.Text = "";
            frmNote.rtbContent.Clear();
            frmNote.lblCreation.Text = (DateTime.Now.ToString());
            if (frmNote.ShowDialog() == System.Windows.Forms.DialogResult.OK)
            {
                ListViewItem myItem = new ListViewItem(frmNote.lblTitle.Text, 0);
                myItem = lvNotes.Items.Add(myItem);
                myItem.SubItems.Add(frmNote.rtbContent.Text);
                myItem.SubItems.Add(frmNote.lblCreation.Text);
                //select the created row 
            }
        }

Open in new window

0
Comment
Question by:peterkiers
  • 3
  • 2
5 Comments
 
LVL 4

Expert Comment

by:jatkin
ID: 36715999
Hi,
Does the .Add method not return the new entry?
You should be able to use this to locate and select in the list...
James
0
 
LVL 1

Author Comment

by:peterkiers
ID: 36716010
No, it doesn't automaticly select the row.

P.
0
 
LVL 4

Accepted Solution

by:
jatkin earned 500 total points
ID: 36716014
It's a while since I did this, but can you not set the 'Selected' property to true?
0
 
LVL 1

Author Comment

by:peterkiers
ID: 36716028
It works. Thanks. Peter
0
 
LVL 4

Expert Comment

by:jatkin
ID: 36716030
No problem.... :-)
0

Featured Post

Master Your Team's Linux and Cloud Stack

Come see why top tech companies like Mailchimp and Media Temple use Linux Academy to build their employee training programs.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

In my previous two articles we discussed Binary Serialization (http://www.experts-exchange.com/A_4362.html) and XML Serialization (http://www.experts-exchange.com/A_4425.html). In this article we will try to know more about SOAP (Simple Object Acces…
Today I had a very interesting conundrum that had to get solved quickly. Needless to say, it wasn't resolved quickly because when we needed it we were very rushed, but as soon as the conference call was over and I took a step back I saw the correct …
Email security requires an ever evolving service that stays up to date with counter-evolving threats. The Email Laundry perform Research and Development to ensure their email security service evolves faster than cyber criminals. We apply our Threat…
A short tutorial showing how to set up an email signature in Outlook on the Web (previously known as OWA). For free email signatures designs, visit https://www.mail-signatures.com/articles/signature-templates/?sts=6651 If you want to manage em…

777 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question