How to suppress a section programmatically in Crystal Reports? - c#

Is there a way to suppress/hide a section programmatically in Crystal Reports???
I need to suppress a section in Crystal Reports when the Change Text in one textbox
Thanks

Add this below code in your code behind file
CrystalDecisions.CrystalReports.Engine.ReportDocument doc=your reportdocument;
doc.DataDefinition.FormulaFields["yourformulaname"].Text = "your value";
//or you can directly set the visibility of your section from code behind on the basis of your business logic as
doc.ReportDefinition.Sections["sectionnameOrIndex"].SectionFormat.EnableSuppress = true;

Go to section expert.
Select your section.
On the right hand side you will notice a suppress checkbox. Check it.
Right beside the check box label you will see a formula button. Click on it. Now you can see a formula editor to write your logic.
In the formula editor write something like this
if {#yourformula}="1" then
true //hide
else
false //do not hide
{yourformula} can be replaced with any field you like.
If you want to set the value of your formula field from code behind then
CrystalDecisions.CrystalReports.Engine.ReportDocument doc=your reportdocument;
doc.DataDefinition.FormulaFields["yourformulaname"].Text = "your value";
//or you can directly set the visibility of your section from code behind on the basis of your business logc as
doc.ReportDefinition.Sections["sectionnameOrIndex"].SectionFormat.EnableSuppress = true;

Related

How to check if text assigned to TextObject grows to next line in Crystal Report

I am using CrystalReportViewer in .aspx page for generating a simple Report liek below:
ReportClass rpt = new Report();
CrystalReportViewer1.ReportSource = rpt;
TextObject txtName = (TextObject)rpt.ReportDefinition.ReportObjects["txtName"];
txtName.Text = GetNameFromDB();
Sometimes the function GetNameFromDB() returns long name and the textObject txtName grows to next line. Is there any way to check if txtName grows to next line or not? How can i check this?
For certain use cases, yes, there is a way. But it requires use of extra code or a Crystal Reports UFL (User Function Library).
But, as suggested by R. McMillan, please explain your use case.
For example, simply placing the objects below the text object in their own section (split section option in Crystal) may offer a simple solution.

UltraGrid Filter cell property

Working on a code that was written by someone else. Here are the important parts of the code:
UltraGridColumn col = columns.Add("FolderImage", "Status");
col.Header.Fixed = true;
col.AllowRowFiltering = Infragistics.Win.DefaultableBoolean.False;
There is more code written to specify the behavior of the folder, but it is irrelevant for the example; As of right now, the following result is generated:
As you can see, there is a greyed out "Filter" button, and the pin is missing:
I want it to look like this:
I.e. filter button needs to go in the status column (it just needs to be blank), and the pin button should be enabled. According to the Infragistics manual, the code above should produce the very results I am looking for, but it does not.
To hide the filter operator (the 'A' letter) you need to set FilterOperatorLocation of the column to Hidden. To show the pin of the fixed column you need to set to its header FixedHeaderIndicator to Button (by the way this is default value, so if you did not override it at some other place you may skip this step). Try to use code like this:
col.FilterOperatorLocation = FilterOperatorLocation.Hidden;
col.Header.FixedHeaderIndicator = FixedHeaderIndicator.Button;
For the "A" button in a cell, the following code fixed it:
col.FilterOperatorLocation = FilterOperatorLocation.Hidden;
For the pin, I had to enable the "UsedFixedHeaders" property:
this.gridName.DisplayLayout.UseFixedHeaders = true;

OpenXML add custom style to Quick Style Gallery

I'm creating a Word Document using OpenXML. During the creation of the document, I need to create some custom styles.
Now I've one problem left: I want to put my custom styles inside the Quick Style Gallery, but I wasn't able to do that. The way that I'm following is explained in the following code:
var info = new LatentStyleExceptionInfo
{
Name = styleid,
PrimaryStyle = true,
UnhideWhenUsed = false,
SemiHidden = false,
UiPriority = 1
};
styleDefinitionsPart.Styles.OfType<LatentStyles>().First().Append(info);
Because I've found a link that tells that is the "PrimaryStyle" attribute responsible for put a Style inside the Quick Gallery.
Another thing: opening the styles.xml file, I've noticed that all the other styles has "1" or "0" for the OnOffValue, whereas the custom styles created with that piece of code has "true" or "false".
How can I solve it?
Thanks.
The XML tag that influences appearance of the style in the quick gallery is <w:qFormat/>. The API property that corresponds is Style.QuickStyle. The Interop name is also QuickStyle (boolean).
Btw, I don't think adding a latent style is going to help you. You'll want to add a real, actual, fully-fledged style if you want it to appear in the UI and be operative.

Compare current values of controls with page load values on keypress

I have an aspx page which contains a no. of div with varying no. of controls.
and evey div is visible through a tab menu i.e. on clicking of a tab in menu a div is made visible or false.
Now for my requirement I want to check if a user has made some changes in the foem fields and if it changes any of the field, a message should be displayed showing "Your changes have not been saved".
How can I accompalish this if you could guide me please.
Thanks in advance.
var formChanged = false;
// doc ready
$('#formId').change(function(){
formChanged = true;
});

Watin Visible of Text

I'm Using Watin tool in C# to find a text is available in webpage/URL. Using the code:
bool flag = browser.containsText("Some Text");
But returns true, but the text("Some Text") is hidden in page. I need to get only visible text of a URL. i Dont Have the ID/Name of the Element...
Find the control that is hidden and check to see if it is visible and contains the text.
Example if it were a Div and using NUnit:
Assert.IsTrue(myBrowser.Div.Style.GetAttributeValue("visibility") == "hidden" && myBrowser.Div("myPossiblyHiddenDiv").Text.Contains("the text"));
Lots of ways to check for the text; I usually try to go as granular as possible in case there are other controls on the page that contain the text in question.

Categories

Resources