0
Hello!
My C# project has a listbox that lists numbers typed by the user. What I want to do is that these numbers are constantly being updated increasingly in the listbox.
I tried to use the Sorted tool, but what happens is: https://puu.sh/zOdxj/9ecded73c4.png
In print: I entered with the values 1,2,3,4,5,6 and when I entered with the value 11, it appeared just below the 1.
Code of the Confirm Value button:
if (tbNumero.Text == "")
{
MessageBox.Show("Não foi digitado nenhum número.", "Erro!", MessageBoxButtons.OK, MessageBoxIcon.Warning);
}
else
{
try
{
lstRoll.Items.Add(Convert.ToDouble(tbNumero.Text));
btnRemoveRoll.Enabled = true;
btnResetAll.Enabled = true;
tbNumero.Text = "";
tbNumero.Focus();
lstRoll.Sorted = true;
}
catch (Exception)
{
MessageBox.Show("Por favor, digite apenas numeros", "Erro", MessageBoxButtons.OK, MessageBoxIcon.Error);
tbNumero.Text = "";
tbNumero.Focus();
}
}
Solved with this video: https://www.youtube.com/watch?v=rKu3m1NwrUU
Elements are sorted as text which is what was stored in
ListBox
– Isac