如何通过单击Crystal Report中的超链接来打开Winform?
问题描述:
大家好,
用户查看Crystal报表.他想同时打开一个特定的翻译表单以进行更正.他怎么做?
请建议我,我该如何实施此问题.看起来像打开winform的超链接.
Hi all,
User views a Crystal report. He wants to open a particular translation form for correction at the same time. How can he do it?
please suggest me ,how can i implement this issue. Looks like a hyperlink that opens winform.
答
我从没想过要这样做,但是我确实有一些托管CrystalReportViewer
控件的表单,认为可以做到的.
该控件引发一个事件ClickPage
,该事件具有一个CrystalDecisions.Windows.Forms.PageMouseEventArgs
参数.它具有属性ObjectInfo
,该属性包含有关所选对象"(大概是用户单击的对象)的信息.如果用户单击链接,则应该可以将其转换并提取有意义的信息.然后,您可以使用此信息来打开翻译表单X.
我没有使用报表中嵌入的链接,所以我可能是错的.仍然....尝试在链接的URL字段中对您的信息进行编码.创建一个伪协议,然后创建一个字段,指出要打开的表单,例如trans:SPA
.当ClickPage
截获点击时,如果对象是链接,并且链接具有以trans:
开头的URL,则可以打开请求的翻译表单.否则,将其视为普通URL.
让我知道这是否可行,我可以看到一些很好的用法.
I''ve never thought to do this, but I do have some forms that host theCrystalReportViewer
control and I think it can be done.
The control raises an event,ClickPage
, which has aCrystalDecisions.Windows.Forms.PageMouseEventArgs
parameter. This has a property,ObjectInfo
, which carries information about "the selected object," presumably, the object that the user clicked. If the user clicked on a link, it should be possible to convert it and extract meaningful information. You can then use this information to open translation form X.
I have not used links embedded in reports, so I may be wrong. Still.... Try encoding your information in the link''s URL field. Create a pseudo protocol, and then a field indicating the form to open, say,trans:SPA
. WhenClickPage
intercepts the click, if the object is a link and the link has a URL that starts withtrans:
you can open the requested translation form. Otherwise, treat it as a normal URL.
Let me know if this works, I can see a few nice uses for this.
我知道这有点晚了,但是你不敢相信我花了多长时间寻找对于这种解决方案,其他大多数相关文章都提到它不可能",因此非常感谢Gregory张贴此文章.
通过添加以下代码,它与我完美协作:
I know it''s a little bit late, but you can''t believe how long I spent looking for such a solution, most of the other related posts mentioned that it''s "NOT POSSIBLE", so thanks a lot Gregory for posting this.
It worked perfectly with me, by adding the following code:
Private Sub CRV_ClickPage(ByVal sender As System.Object, ByVal e As CrystalDecisions.Windows.Forms.PageMouseEventArgs) Handles CRV.ClickPage
If e.ObjectInfo.Name = "vouCode" Then
Dim frmToLoad As New Services
frmToLoad.LoadOrders(e.ObjectInfo.Text)
frmToLoad.Show()
End If
End Sub
e.ObjectInfo.Name
将返回IFieldObject名称,而e.ObjectInfo.Text
将返回其文本.
Where e.ObjectInfo.Name
will return the IFieldObject name, and e.ObjectInfo.Text
will return it''s text.