<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>solo VB.NET - Visual Basic .Net &#187; Featured</title>
	<atom:link href="http://www.solovb.net/index.php/category/featured/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.solovb.net</link>
	<description>Visual Basic.NET, VB.NET, Programación, Tutoriales, Ejemplos</description>
	<lastBuildDate>Mon, 02 Jan 2012 14:30:00 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3</generator>
		<item>
		<title>Listview: Item siempre visible</title>
		<link>http://www.solovb.net/index.php/2009/10/15/listview-item-siempre-visible/</link>
		<comments>http://www.solovb.net/index.php/2009/10/15/listview-item-siempre-visible/#comments</comments>
		<pubDate>Thu, 15 Oct 2009 03:46:00 +0000</pubDate>
		<dc:creator>Eliseo</dc:creator>
				<category><![CDATA[Controles]]></category>
		<category><![CDATA[Ejemplos]]></category>
		<category><![CDATA[Featured]]></category>
		<category><![CDATA[Tutoriales]]></category>
		<category><![CDATA[add]]></category>
		<category><![CDATA[agregar item]]></category>
		<category><![CDATA[ListView]]></category>
		<category><![CDATA[listviewitems]]></category>
		<category><![CDATA[siempre visible]]></category>

		<guid isPermaLink="false">http://www.solovb.net/index.php/2009/10/15/listview-item-siempre-visible/</guid>
		<description><![CDATA[Siempre que se agregan nuevos elementos ListviewItems a un control listview, y estos son tantos que el control no tiene espacio suficiente para mostrarlos en pantalla, se agrega una barra de desplazamiento vertical. Esto está perfecto, solo que por default no se ven los nuevos items que se van agregando. Hoy quiero mostrarles como solucionar [...]]]></description>
			<content:encoded><![CDATA[<p>Siempre que se agregan nuevos elementos <strong>ListviewItems</strong> a un control <strong>listview</strong>, y estos son tantos que el control no tiene espacio suficiente para mostrarlos en pantalla, se agrega una barra de desplazamiento vertical. Esto está perfecto, solo que por default no se ven los nuevos items que se van agregando.</p>
<p>Hoy quiero mostrarles como solucionar este pequeño inconveniente.</p>
<p>Los controles de <strong>visual basic .net</strong> cono el <strong>listview</strong> nos brindan una cantidad impresionante de <strong>propiedades</strong> para su <strong>configuración</strong>, tantas que muchas veces se desconocen.</p>
<p>Quiero mostrarlo con un <strong>ejemplo muy sencillo</strong>. Para ello necesitaremos un formulario, un control listview y un botón.</p>
<p><a href="http://www.solovb.net/wp-content/uploads/2009/10/listviewItemSiempreVisible001.jpg"><img style="border-top-width: 0px; display: block; border-left-width: 0px; float: none; border-bottom-width: 0px; margin-left: auto; margin-right: auto; border-right-width: 0px" title="listviewItemSiempreVisible001" src="http://www.solovb.net/wp-content/uploads/2009/10/listviewItemSiempreVisible001_thumb.jpg" border="0" alt="listviewItemSiempreVisible001" width="437" height="514" /></a></p>
<p>Las propiedades que mas nos interesan son las siguientes:</p>
<ul>
<li><strong>HideSelection</strong>: la establecemos en false para que aunque el control listview no tenga el foco, sigamos viendo cual es el item seleccionado.</li>
<li><strong>ListView1.FocusedItem.EnsureVisible()</strong> para forzar al item seleccionado a estar siempre visible.</li>
</ul>
<p>Bueno, ahora si el código:</p>
<pre class="brush: vbnet; ruler: false; first-line: 1; highlight: [14]">
    Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        ListView1.HideSelection = False
        ListView1.FullRowSelect = True
        ListView1.MultiSelect = False
    End Sub

    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        Static i As Integer = 0
        i += 1
        ListView1.Items.Add(New ListViewItem("Item número " &#038; i))
        ListView1.Items(ListView1.Items.Count - 1).Selected = True
        ListView1.Items(ListView1.Items.Count - 1).Focused = True

        ListView1.FocusedItem.EnsureVisible()
    End Sub
</pre>
<p>Al ejecutarlo debería verse muy parecido a lo que se muestra en esta imagen:</p>
<p><a href="http://www.solovb.net/wp-content/uploads/2009/10/listviewItemSiempreVisible002.jpg"><img style="border-top-width: 0px; display: block; border-left-width: 0px; float: none; border-bottom-width: 0px; margin-left: auto; margin-right: auto; border-right-width: 0px" title="listviewItemSiempreVisible002" src="http://www.solovb.net/wp-content/uploads/2009/10/listviewItemSiempreVisible002_thumb.jpg" border="0" alt="listviewItemSiempreVisible002" width="366" height="446" /></a></p>
<p>Eso es todo, si te sirvió esta información, por favor, deja un comentario.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.solovb.net/index.php/2009/10/15/listview-item-siempre-visible/feed/</wfw:commentRss>
		<slash:comments>11</slash:comments>
		</item>
	</channel>
</rss>

