Select ListView Item Programmatically
This simple code will allow you to programmatically select an item in a listview. Hope this helps.
AI
Resumo por IA: This codebase represents a historical implementation of the logic described in the metadata. Our preservation engine analyzes the structure to provide context for modern developers.
Código fonte
<html> <head> <title></title> <meta name="GENERATOR" content="Microsoft Visual Studio.NET 7.0"> <meta name="vs_targetSchema" content="http://schemas.microsoft.com/intellisense/ie5"> </head> <P><STRONG><FONT color="#990000">How to select a ListView Item Programmatically.</FONT></STRONG></P> <P> </P> <P><FONT color="#990000">This is a simple process, but most people forget a little step in doing this.</FONT></P> <P><FONT color="#000099" size="4"><STRONG>Step 1:</STRONG></FONT></P> <P><STRONG><FONT color="#000099" size="4">Create a ListView Item and name it to whatever you wish. I will use <FONT color="#ff0000">lv</FONT> for simplicity.</FONT></STRONG></P> <P><STRONG><FONT color="#000099" size="4">Step 2:</FONT></STRONG></P> <P><STRONG><FONT color="#000099" size="4">Create a Button Item </FONT></STRONG> </P> <P><STRONG><FONT color="#000099" size="4">Step 3:</FONT></STRONG></P> <P><STRONG><FONT color="#000099" size="4">Double Click the Button to start typeing code.</FONT></STRONG></P> <P><STRONG><FONT color="#000099" size="4"></FONT></STRONG> </P> <P><STRONG><FONT color="#000099" size="4">Step 4:</FONT></STRONG></P> <P><FONT color="#993399">Enter the following code:</FONT></P> <P><FONT color="#0066ff">Private Sub Button1_Click(......) Handles Button1.Click</FONT></P> <P><FONT color="#990033"> lv.Items(0).Selected = True</FONT></P> <P><FONT color="#990033"> lv.Select() </FONT><FONT color="#009900"> 'This is what most people forget. If you don't put this in here, it will never select the item in the list view.</FONT></P> <P><FONT color="#0066ff">End Sub</FONT></P> <P><FONT color="#0066ff"><STRONG>And that is it! Really Really simple, but very useful.</STRONG></FONT></P> <P><FONT color="#0066ff"></FONT> </P> <P><STRONG><FONT color="#000099">Step 5:</FONT></STRONG></P> <P><STRONG><FONT color="#000099">If you find this code useful. Vote for me. </FONT></STRONG> </P> </html>
Comentários originais (3)
Recuperado do Wayback Machine