This issue is driving me crazy..
This code raises index out of range exception for the messagebox:
private void MainTabs_Selected(object sender, TabControlEventArgs e)
{
if (MainTabs.SelectedTab.Name == "ActiveDirectoryTab")
{
ADServerSelect.Items[0].Selected = true;
MessageBox.Show(ADServerSelect.Items[0].Text);
}
}
But if the messagebox is the result of an event it works just fine:
private void MainTabs_Selected(object sender, TabControlEventArgs 开发者_如何学Ce)
{
if (MainTabs.SelectedTab.Name == "ActiveDirectoryTab")
{
ADServerSelect.Items[0].Selected = true;
}
}
private void testButton_Click(object sender, EventArgs e)
{
MessageBox.Show(ADServerSelect.Items[0].Text);
}
Any help would be greatly appreciated..
looks like items added to the listview AFTER MainTabs_Selected event. can you check it?
精彩评论