开发者

Weird listview behavior?

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?

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜