如何模拟鼠标单击? [英] How Do You Simulate a Mouse Click?

查看:116
本文介绍了如何模拟鼠标单击?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个带有6个标签的标签控件。 我想要一个特定的选项卡进入视图并显示其内容 - 就像用户在其上单击鼠标一样 - 基于表单上的用户交互。 例如在一个标签上有一个包含股票信息的数据网格,当使用双击带有股票代码的列时,我会在另一个标签上加载该图表的图表。 这样可以正常工作,但是我没有能够在没有实际点击选项卡的情况下将图表弹出视图。

我试过了:

tabControl1.TabPages [( int TabSet1 。图表] .Select();
tabControl1.TabPages [(
int TabSet1 。图表] .Focus();

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();

tabControl1.TabPages [( int TabSet1 。图表]。显示();

我接近一点 - 但没有雪茄。 使用此行,当前选项卡变为空白(数据网格和按钮消失),但所需的选项卡仍然保持着诱人的隐藏。


请注意,我不一定要尝试调用任何代码。 tabcontrol的Click()事件,只需使所需的选项卡成为活动控件并显示其内容,而无需用户实际点击它。

TIA
rca

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

推荐答案

您可以使用TabControl的SelectedTab或SelectedIndex属性。

例如:tabControl1.SelectedIndex = 2
将左侧的第3个选项卡设置为选定的选项卡。

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.


这篇关于如何模拟鼠标单击?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆