Click here to Skip to main content
15,898,745 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
1. Loading tabpage works fine on click event as it is under same class(Case1).
2. I am calling OnListItemActivate( null, null); (see case2 code it is entering condition properly but unable to load tabpage).

Please suggest me the way of loading without clicking on listview item.
Is it possible to load something without click event through code ..?

C#
// Case 1 : Works fine on click
this.listView1.ItemActivate += new System.EventHandler(this.OnListItemActivate);

C#
public partial class Routes
{

    //Case 2 : I want to load tab page2
    public void Back_to_view_Route_page()
    {
    listView1.Items[1].Focused = true;
    listView1.Items[1].Selected = true;

    OnListItemActivate( null, null);
    }

  // works fine for case1 not for case2

    public void OnListItemActivate(object sender, EventArgs e)
    {

    if (listView1.FocusedItem == listView1.Items[0])
    {
    // Load tab page 1
    ----------
    this.tabControl1.SelectedIndex = 1;
    }
    else if (listView1.FocusedItem == listView1.Items[1])
    {
    // Load tab page 2
    -------------
    this.tabControl1.SelectedIndex = 2;
    }
  }
}
Posted
Comments
Tomas Takac 20-Nov-14 5:08am    
Why not do tabControl1.SelectedIndex = 1 directly instead of calling OnListItemActivate(null, null)?
shivashankar R G 21-Nov-14 7:35am    
I tried that but not working. Thank u for the response.
Additional information:
1. I am traveling back from Display.cs -> Route.cs

XX.YY.GUI.Screens.Routes r1 = new Routes();
public override void OnBack()
{
XX.YY.Main.Program.Instance.stack.Push<xx.yy.gui.screens.routes>();
r1.Back_to_view_Route_page();
}

2. I am pushing "Routes" on Stack -> In Routes I have listview items each pointing to one of the tab page.
3. The control is going in but fail to load

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900