在不知道其名称的情况下手动选择控件的元素...(ReportViewer)

发布于 2024-08-07 22:30:25 字数 664 浏览 5 评论 0原文

我正在我的 C# 应用程序中使用 ReportViewer 类,并且有一个问题并不需要解决,但我想弄清楚。

假设我启动了一个新表单,其中包含完全停靠的报表查看器控件,当表单加载时,报表查看器已刷新并显示我的报表。

在几乎所有情况下,报告都会比表单的垂直尺寸更长,因此会有垂直滚动条。

我想做的是找出一种方法来为报表查看器控件的“报表区域”部分提供焦点或选择,以便在加载表单时 - 我可以立即使用鼠标上的滚轮向上移动并查看报告

实际发生的情况是,在我单击报告区域之前,滚动条不起作用。

有谁知道如何关注这一特定领域?

这是我试图重点关注该区域的一些代码...

int x = this._ReportViewer.Location.X + (this._ReportViewer.Width / 2);
int y = this._ReportViewer.Location.Y + (this._ReportViewer.Height / 2);

this._ReportViewer.RenderingComplete += delegate
{
    this.OnMouseClick(new MouseEventArgs(MouseButtons.Left, 1, x, y, 1));
};

谢谢!

i am utilising the reportviewer class in my c# application and have a question that isnt essential to fix but something i would like to figure out.

Lets say i launch a new form with a fully docked reportviewer control inside and by the time the form loads the reportviewer has refreshed and is showing my report.

In almost all cases the report will be longer that the vertical size of the form and hence there will be vertical scrollbars.

What i would like to do is figure out a way to give the 'report area' part of the reportviewer control focus or selection so that when the form has loaded - i can immediately use the scroll wheel on my mouse to move up and down the report.

What actually happens is the scroll bars do not work until i click on the report area.

Does any one know how to give that particular area focus?

Here is some of the code i have tried to give that area focus...

int x = this._ReportViewer.Location.X + (this._ReportViewer.Width / 2);
int y = this._ReportViewer.Location.Y + (this._ReportViewer.Height / 2);

this._ReportViewer.RenderingComplete += delegate
{
    this.OnMouseClick(new MouseEventArgs(MouseButtons.Left, 1, x, y, 1));
};

Thanks!

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

眼泪都笑了 2024-08-14 22:30:25

我想到的一个想法是递归地循环访问 ReportViewer 控件。点击报告区域后,将焦点设置到该控件上。

这是一个示例片段:

   //Call this function, by passing it your reportViewer control
   private void RecurseControls(Control ctrl)   
   {
       foreach (Control c in ctrl.Controls) {  //Put breakpoint here to see the controls being looped

           if (c is <TYPEOFCONTROLYOURLOOKINGFOR>) {              
               //CAST c AND SET FOCUS TO IT
           }

           if (c.HasChildren) {  //recurse if children controls exist
               CustomizeRV(c);
           }
       }
   }

One idea that comes to mind is to loop through the ReportViewer controls recursively. Upon hitting the report area, set focus to that control.

Here is an example snippet:

   //Call this function, by passing it your reportViewer control
   private void RecurseControls(Control ctrl)   
   {
       foreach (Control c in ctrl.Controls) {  //Put breakpoint here to see the controls being looped

           if (c is <TYPEOFCONTROLYOURLOOKINGFOR>) {              
               //CAST c AND SET FOCUS TO IT
           }

           if (c.HasChildren) {  //recurse if children controls exist
               CustomizeRV(c);
           }
       }
   }
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文