string[] test = myListBox.SelectedItem.ToString().Split(new char[] {' '});
if (test.Length > 0)
MessageBox.Show(test[0]);
or, in some cases,
string[] test = myListBox.SelectedItem.ToString().Split(new char[] {' '}, System.StringSplitOptions.RemoveEmptyEntries);
if (test.Length > 0)
MessageBox.Show(test[0]);
By the way, pay attention for violation of the naming conventions in
listBox1
. Auto code generation by designer simply cannot (and should not) do better, but it's your business to rename all auto-generated names to something semantically sensible; never use auto-generated names as is.
—SA