Solved

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

Posted on 2011-09-28
5
185 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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

MS Dynamics Made Instantly Simpler

Make Your Microsoft Dynamics Investment Count  & Drastically Decrease Training Time by Providing Intuitive Step-By-Step WalkThru Tutorials.

Question has a verified solution.

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

Suggested Solutions

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…
This article aims to explain the working of CircularLogArchiver. This tool was designed to solve the buildup of log file in cases where systems do not support circular logging or where circular logging is not enabled
In an interesting question (https://www.experts-exchange.com/questions/29008360/) here at Experts Exchange, a member asked how to split a single image into multiple images. The primary usage for this is to place many photographs on a flatbed scanner…
I've attached the XLSM Excel spreadsheet I used in the video and also text files containing the macros used below. https://filedb.experts-exchange.com/incoming/2017/03_w12/1151775/Permutations.txt https://filedb.experts-exchange.com/incoming/201…

740 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