RDLC text overflow behavior - c#

I'm working on converting an older reporting format into RDLC and am running into a problem. In a few edge cases a numeric value overruns its allotted display space -- it's, let's say, '10000%', and I can't just set "CanGrow" to false and let the field truncate since the percent sign must be visible.
In the original reporting format a field too big for its allotted display space just displayed as a bunch of asterisks, so I've got a question in two parts:
1) Is there a way to format the data in RDLC so it displays an alternate string if it runs over a certain value?
2) Is there a way to apply that format for printing only, so that on exporting the data to, say, Excel (with Report.Render) the field will still say '10000%'?

For posterity, what worked here was combining the Globals!RenderFormat field with filtering based on the value. For example
IIF(Globals!RenderFormat.Name Like "excel*" Or
(Fields!Percent1.Value > -10 And Fields!Percent1.Value < 100),
Fields!Percent1.Value, "******")

Related

iText7 Dynamically Set Field Calculation At Run-time

Working with iText7 library version 7.0.2.2 in a c# web application. A PDF document is produced with n-number of dynamically created pages based on the amount of data.
Is there a way to set a field with a calculated formula at run time? So for example, something along the lines of having a subtotal field calculation like
the product of Page1.Lineitem1.qty and Page1.LineItem1.unitprice.
Itext is merely creating the view, the data model feeding it is provided by you.
Furthermore, itext only draws text strings, not numerical types, so it would have to parse those strings back to numbers which can be difficult considering all the ways numbers can be formatted with commas, periods, plus and minus signs, brackets, units,...
And the text pieces you draw with itext are not named.
And itext flushes contents to the output as soon as possible to save memory.
...
So no, itext does not provide support for "the product of Page1.Lineitem1.qty and Page1.LineItem1.unitprice" or similar expressions.

General number formatting (#,00) in mvc asp.net and switching between formats

My main problem is that i need to be able to have asp.mvc accept the Danish number format (meaning a dot every thousand and a comma seperator). Since i am working on a larger system, I need a more in-depth solution.
The formating problem includes the fact that I need to beable to solve the errorhandling aswell, which does not accept the 0,00 as a number. best case, the solution still maintains the possibility to calculate with the numbers without having to format them each time.
As another point, I need to beable to switch between the English format, meaning (0.00) and the Danish (0,00).
TL;DR
Solve the problem of using a diffrent formatting in mvc asp.net from (en 0.00) to (da 0,00), including errorhandling, still allowing for calculations in jquery or javascript, and the posibility to switch back to the english format (0.00).
What would be the best way to go about this?
Edit: Solved most of it!
To get the View (Jquery validate) to accept comma as a seperator I've inserted "One regexp" from this: http://mfranc.com/javascript/jquery-valdiator-modyfing-decimal-separator/
Adding the custom model binding, provided by #chrispratt solved the problem of the controller receiving the number in the right format.
On top of this I've added code to modify any number entered into an input field into the right format.
Also all numbers and their display formats are checked before being shown. (since some doubles display without ,00)
I think that should be it, now all that remains is to devise some method of switching between languages and formats, which I should beable to manage.
Thanks for the help!
Any help is apprichiated!
Thanks in advance!

C# Custom display formatting for String fields

I would like to be able to apply the following display masks in c# to doubles to produce formatted strings.
For example I want the following display masks:
0;(0) to produce a format like 126524
0,.00;(0,.00) gives 183.94
Total Spend: €0,.00;(0,.00) -> "Total Spend €12.34"
0 Days -> "0 Days"
The display masks are input by a user so can be wide in nature. They can also contain text. I have been able to do similar using a DevExpress AspxGridView, a column has a DisplayFormatString that I can use.
e.g. I have a variable named FormatString (e.g. "Total Spend: €0,.00;(0,.00)") which a user enters, I can assign to a grid column like:
columnDisplayFormatString = FormatString
I need to do something similar in a Web Service so can't use any third party UI components.
I know I can always parse the format string and derive the parameters needed for String.Format but this could get quite messy.
There's alot of information available here about string formats:
http://msdn.microsoft.com/en-us/library/0c899ak8.aspx

Access 2010 + Datagridview Decimal Issue

I seem to be having and issue with the decimal option in access 2010.
The images below demonstrate the problem that I am having, one image shows normal 0's in empty cells within Access 2010, however when this data is moved to a datagridview the number becomes 3 decimal places (0.000).
The final image displays the options that have been selected within the Qty Open field, this is for information purposes to try and get to the bottom of the problem.
The main issue I believe that is causing this is the Scale option in Access, when this is removed the datagridview displays the number without the additional decimal places. However by removing this option disallows me to enter any decimal places.
You don't want to modify the underlying datatype on the Access Database for this. Instead you should be modifying how the data is displayed
To do this just set the Format Property on the Column's DefaultCellStyle using a Custom Format Specifier using the Digit placeholder #
Replaces the pound sign with the corresponding digit if one is
present; otherwise, no digit appears in the result string
e.g.
this.dataGridView1.Columns["Wastage"].DefaultCellStyle.Format = "#,0.###";
All you need is display the end result properly. Try this:
private decimal GetDecimalValue(decimal d)
{
return d / 1.00000000000000000000000000000m;
}
Call this before you display the result.

textbox properties

I have set the MaxLength property of a textbox in my windows forms application to 10
I am populating the textbox by reading from a file. However if a read string which is more than 10 characters the textbox still gets populated. But when I manually try to enter a string it works fine (that is, it does not allow more than 10 characters to be entered).
Why is there a difference between these two behaviors? How can I populate my textbox from the file and still have the MaxLength property to be working?
Thanks,
Viren
From the TextBoxBase.MaxLengthProperty specs:
In code, you can set the value of the Text property to a value that has a length greater than the value specified by the MaxLength property. This property only affects text entered into the control at run time.
In other words, you must limit the amount of text in code when pulling from a data source.
For Example:
string text = "The quick blue smurf jumped over the brown fox.";
textBox1.Text = text.Substring( 0, textBox1.MaxLength );
It's never wise to rely entirely on instant validation of values - you should always validate the final value as well. For example, i've seen people regularly using KeyUp/KeyDown/KeyPress events to disallow various characters, and then forgetting that people regularly use copy-and-paste (which negates the intended validation).
You'll have to limit it programatically. That's simply the way the browsers treat HTML. Sorry :(
Unfortunately, the HTML spec doesn't offer any guidance on this issue (that I can find) so the browser makers have settled on this behavior.
http://www.w3.org/TR/html401/interact/forms.html#h-17.4
At the very worst, you could try to limit your data to 10 characters when you are binding to the textbox:
txtMyTextbox.Text = Left(myData, 10)

Categories

Resources