Skip to content

Instantly share code, notes, and snippets.

@Fhernd
Created February 27, 2018 23:17
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Fhernd/5b1a6505bbe3ae9d0381b46e868993de to your computer and use it in GitHub Desktop.
Save Fhernd/5b1a6505bbe3ae9d0381b46e868993de to your computer and use it in GitHub Desktop.
Desplazar el scroll de un ListBox al elemento recién agregado. C#.
using System;
using System.Windows.Forms;
namespace R707DesplazarListBox
{
public partial class Principal : Form
{
public Principal()
{
InitializeComponent();
}
private void btnAgregarElementos_Click(object sender, EventArgs e)
{
for (int i = 1; i <= 20; i++)
{
lbxElementos.Items.Add("Elemento no. " + i.ToString());
}
lbxElementos.TopIndex = lbxElementos.Items.Count - 1;
lbxElementos.SelectedIndex = lbxElementos.Items.Count - 1;
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment