[Last Call] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 193
  • Last Modified:

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

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
peterkiers
Asked:
peterkiers
  • 3
  • 2
1 Solution
 
James AtkinSenior Principle Software EngineerCommented:
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
 
peterkiersAuthor Commented:
No, it doesn't automaticly select the row.

P.
0
 
James AtkinSenior Principle Software EngineerCommented:
It's a while since I did this, but can you not set the 'Selected' property to true?
0
 
peterkiersAuthor Commented:
It works. Thanks. Peter
0
 
James AtkinSenior Principle Software EngineerCommented:
No problem.... :-)
0

Featured Post

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

  • 3
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now