Good day! I would like to have help with my simple code from our programming project. My problem is that I can't find a solution on how to randomize text items in the listbox. The items are read from my MS Access database. Here is some of my code.
Com.CommandText = "SELECT * FROM search";
OleDbDataReader reader = Com.ExecuteReader();
object[] obj = new object[256];
while (reader.Read())
{
reader.GetValues(obj);
if (label1.Text == obj[0].ToString())
{
listBox1.Items.Add(reader.GetString(1));
listBox1.Items.Add(reader.GetString(2));
listBox1.Items.Add(reader.GetString(3));
listBox1.Items.Add(reader.GetString(4));
}
}
reader.Close();
conn.Close();
Random random = new Random();
string[] words = { listBox1.Items.ToString() };
listBox4.Items.Add(words[random.Next(0, words.Length)]);
And it won't work.