本文介绍了Crystal Report以编程方式排序的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述





我想知道怎样才能进行编程排序,我发现下面的例子

来自bellow链接: []

Hi,

I want to know how can I make a programaticly sort, I found the bellow example
from the bellow link: http://social.msdn.microsoft.com/forums/en-US/csharpgeneral/thread/49ed286b-5aea-4414-b58a-9f10601eb076[^]

SortFields sortFields = m_Report.DataDefinition.SortFields;
sortFields[0].Field = m_Report.Database.Tables[table].Fields[field];
sortFields[0].SortDirection = CrystalDecisions.Shared.SortDirection.AscendingOrder;





我有三个排序参数的问题,(Sub_id,Gen​​der和JobCateg),这个例子不能用它,



在此先感谢

Otto



The problem that I have three sort parameter,(Sub_id,Gender and JobCateg), that example don't work with it,

Thanks in Advance
Otto

推荐答案

OP写道:

我发现了吼叫示例

来自下面的链接:http://social.msdn.microsoft.com/forums/en-US/csharpgeneral/thread/49ed286b-5aea-4414-b58a-9f10601eb076 [^]

I found the bellow example
from the bellow link: http://social.msdn.microsoft.com/forums/en-US/csharpgeneral/thread/49ed286b-5aea-4414-b58a-9f10601eb076[^]



可悲的是,这不是一个解决方案的链接,也有OP问你的问题。

别担心我会给你解决方案。



你去吧

[]




Sadly it's not a solution link, there also the OP asked the question like you.
Don't worry I'll give you solution.

Here you go
C#: Adding many SortField to a CrystalReportViewer using reflection[^]

OP写道:

提前谢谢



关闭主题,最近我看了电影 [],其中,前导字符名称 Otto 是回文:)


Off Topic, Recently I saw the movie Lovers of the Arctic Circle[^], In that, the leading character name also Otto which is palindrome :)



Hello, It is working fine

Dim fieldDef As DatabaseFieldDefinition = ReportDoc.Database.Tables(crTable.Name).Fields(crField.Name)
getRasSorts = targetSortField.[GetType]().GetMethod("get_RasSorts", BindingFlags.NonPublic Or BindingFlags.Instance)
rasSorts = getRasSorts.Invoke(targetSortField, System.Type.EmptyTypes)
addSort = rasSorts.[GetType]().GetMethod("Add")
rasAssembly = getRasSorts.ReturnType.Assembly
ciRasSort = rasAssembly.[GetType]("CrystalDecisions.ReportAppServer.DataDefModel.SortClass").GetConstructor(BindingFlags.[Public] Or BindingFlags.Instance, Nothing, System.Type.EmptyTypes, Nothing)
rasSort = ciRasSort.Invoke(System.Type.EmptyTypes)
setSortField = rasSort.[GetType]().GetMethod("set_SortField", BindingFlags.[Public] Or BindingFlags.Instance)
Dim getRasField As MethodInfo = fieldDef.[GetType]().GetMethod("get_RasField", BindingFlags.NonPublic Or BindingFlags.Instance)
Dim rasField As Object = getRasField.Invoke(fieldDef, System.Type.EmptyTypes)
addSort.Invoke(rasSorts, New Object() {rasSort})
setSortField.Invoke(rasSorts, New Object() {rasField})
Dim n As Integer = ReportDoc.DataDefinition.SortFields.Count - 1
targetSortField(n).Field = fieldDef
targetSortField(n).SortDirection = CrystalDecisions.[Shared].SortDirection.AscendingOrder


这篇关于Crystal Report以编程方式排序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-05 07:16