Solved

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

Posted on 2011-09-28
5
175 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
Comment Utility
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
Comment Utility
No, it doesn't automaticly select the row.

P.
0
 
LVL 4

Accepted Solution

by:
jatkin earned 500 total points
Comment Utility
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
Comment Utility
It works. Thanks. Peter
0
 
LVL 4

Expert Comment

by:jatkin
Comment Utility
No problem.... :-)
0

Featured Post

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

This document covers how to connect to SQL Server and browse its contents.  It is meant for those new to Visual Studio and/or working with Microsoft SQL Server.  It is not a guide to building SQL Server database connections in your code.  This is mo…
Exception Handling is in the core of any application that is able to dignify its name. In this article, I'll guide you through the process of writing a DRY (Don't Repeat Yourself) Exception Handling mechanism, using Aspect Oriented Programming.
Excel styles will make formatting consistent and let you apply and change formatting faster. In this tutorial, you'll learn how to use Excel's built-in styles, how to modify styles, and how to create your own. You'll also learn how to use your custo…
Get a first impression of how PRTG looks and learn how it works.   This video is a short introduction to PRTG, as an initial overview or as a quick start for new PRTG users.

762 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

Need Help in Real-Time?

Connect with top rated Experts

6 Experts available now in Live!

Get 1:1 Help Now