How Do You Simulate a Mouse Click?

I have a tab control with 6 tabs.  I want a specific tab to come into view and display its contents - just as if the user has clicked the mouse on it - based on user interaction on the form.  e.g. On one tab there is a datagrid with stock information, and when the use double-clicks on the column with the stock symbol, I load the graph for that chart on another tab.  This works fine, but I haven't been able to then have the chart pop into view without physically clicking on the tab.

I have tried:

tabControl1.TabPages[(int)TabSet1.CHARTING].Select();
tabControl1.TabPages[(
int)TabSet1.CHARTING].Focus();

to no effect.  TabSet1 is an enumeration for the tabs.

If I then add this line:

tabControl1.TabPages[(int)TabSet1.CHARTING].Show();

I get a little closer -- but no cigar.  With this line, the current tab goes blank (the datagrid and buttons disappear) but the desired tab still remains tantalizingly hidden.


Note that I am not necessarily trying to invoke any code in the tabcontrol's Click() event, just make the desired tab become the active control and display its contents without the user having to physically click on it.

TIA
rca



Answer this question

How Do You Simulate a Mouse Click?

  • kingofrain

    You can use TabControl's SelectedTab or SelectedIndex property.

    For example: tabControl1.SelectedIndex = 2

    sets the 3rd tab from the left as the selected tab.


  • David Edwards

    No.  That doesn't do a thing.  Still have the original tab showing.

    --rca

  • How Do You Simulate a Mouse Click?