c# - How to hide options in crystal report file format dialogue -
i using crystal report in visual studio 2012 asp.net c#.i want hide options crystal report dialogue because not working correctly.option following
1- microsoft word (97-2003)data 2-microsoft excel (97-2003)data 3-xml
etc... how can hide these options crystal report.
we need assign onload event handler reportviewer control shown below.
<rsweb:reportviewer id="reportviewer1" runat="server" width="600" onload="reportviewer_onload"> </rsweb:reportviewer>
then inside event handler write code hide export option in export button dropdown.
all export options in reportviewer control available through listrenderingextentionslist method. list need find extension of export option wish hide, have done matching extension name in lambda expression query.
once extension found need access m_isvisible
property using reflection , set false.
protected void reportviewer_onload(object sender, eventargs e) { string exportoption = "excel"; //string exportoption = "word"; //string exportoption = "xml"; renderingextension extension = reportviewer1.localreport.listrenderingextensions().tolist().find(x => x.name.equals(exportoption,stringcomparison.currentcultureignorecase)); if (extension != null) { system.reflection.fieldinfo fieldinfo = extension.gettype().getfield("m_isvisible", system.reflection.bindingflags.instance | system.reflection.bindingflags.nonpublic); fieldinfo.setvalue(extension, false); } }
Comments
Post a Comment