如何使用 VB.Net 在 Data Dynamics.ActiveReports 2.0 中使用图形?

发布于 2024-08-20 14:01:16 字数 388 浏览 3 评论 0原文

我想在活动报告中的文本框背景上应用渐变颜色。为此,我使用图形并使用以下代码:

 Dim a As New System.Drawing.Drawing2D.LinearGradientBrush(New RectangleF(0, 0, Me.Width, Me.Height), color1, color2, mode)
        Dim g As Graphics = Me.CreateGraphics
        g.FillRectangle(a, New RectangleF(0, 0, Me.Width, Me.Height))
        g.Dispose()

它在表单中运行良好,但在报告中无法通过 Me.CreateGraphics 获取图形对象。请建议

I am want to apply gradient color on textbox background in active report. For this I use graphics and use following code:

 Dim a As New System.Drawing.Drawing2D.LinearGradientBrush(New RectangleF(0, 0, Me.Width, Me.Height), color1, color2, mode)
        Dim g As Graphics = Me.CreateGraphics
        g.FillRectangle(a, New RectangleF(0, 0, Me.Width, Me.Height))
        g.Dispose()

It works well in forms but in report not able to get object of Graphics by Me.CreateGraphics. Please suggest

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

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

发布评论

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

评论(1

温柔女人霸气范 2024-08-27 14:01:16

您可以使用 Picture 控件在 ActiveReports 中完成此操作。只需将渐变图像添加到 ActiveReports 图片控件中,并将图片控件放置在与文本框相同的位置即可。考虑到文本框可能会根据运行时的数据增大收缩量(由于 CanGrow 和 CanShrink 属性),您应该在包含文本框和文本框的部分的格式事件中使用以下代码:图片控制:

public void Detail1_Format()
{
    this.gradientPicture.Height = this.txtCustomerID1.Height;   
}

仅供参考:您使用的 CreateGraphics 技术是 Windows 窗体特定的绘画方式。除了在 Windows 窗体中工作之外,ActiveReports 还必须在 Windows 窗体以外的环境中工作,因此不幸的是,我们无法在 ActiveReports 中使用这种精确的技术。

您还可以使用 DataDynamics.ActiveReports.Document.Page 类在 ActiveReports 页面上绘图,其方式与在 Graphics 上绘图的方式类似。不幸的是,将每个文本框映射到每个页面的相应位置有点棘手,需要在文本框上绘制渐变,所以我认为前一种解决方案是最好的。

我还向 ActiveReports 产品管理团队提出了一项建议,要求他们考虑一项功能,以便在未来提供更好的方法来实现这一目标。它将在案例 #142836 下进行跟踪。

我希望这有帮助!

You can accomplish this in ActiveReports using Picture control. Just add a gradient image to the ActiveReports Picture control and place the picture control in the same location as the textbox. To account for the fact that the textbox may grow our shrink based on the data at runtime (due to the CanGrow and CanShrink properties) you should use the following code in the format event of the section containing the textbox & picture control:

public void Detail1_Format()
{
    this.gradientPicture.Height = this.txtCustomerID1.Height;   
}

FYI: The CreateGraphics technique you used is a Windows Forms specific way to do painting. In addition to working in windows forms, ActiveReports has to work in environments other than Windows Forms, so unfortunately we cannot use this exact technique with ActiveReports.

You can also draw onto an ActiveReports page using the DataDynamics.ActiveReports.Document.Page class in a similar way to the way you draw on a Graphics. Unfortunately, it is a bit tricky to map each textbox to it's corresponding position a every page which would be needed to draw the gradients on the textbox so I think the former solution is best.

I also entered an suggestion for the ActiveReports product management team to consider a feature to enable a better way to do this in the future. It will be tracked under case #142836.

I hope this is helpful!

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