1
I have the following string:
string frase = string.Format("A data de hoje é: {0}", DateTime.Now.Date);
Is there any way to make the parameter bold?
1
I have the following string:
string frase = string.Format("A data de hoje é: {0}", DateTime.Now.Date);
Is there any way to make the parameter bold?
5
Edit:
pass the value to your variable:
string frase = $"A data de hoje é: <b>{DateTime.Now.Date}</b>";
On the spot that your XRLabels
receives the variable frase
, replace the XRLabels
by a XRRichText
.
XRLabels
are intended to display plain text only.
XRRichText
was specifically designed to display formatted text in your reports.
I can’t use it like this, I can’t access the xrLabel
directly. I send the data to a business class, to treat together with other data and then start to compile a report.
In which part do you access the xrLabel? in the business class? is just you use this way there...
Somewhere you will get access to the label class and you will get the phrase parameter. Pass it as described above and in the method you have access to xrLabel, you do this setting. If you need help with this, just post the location you send the string and the class you receive.
edited the post, see if it helps...
I tried to use your example, but xrLabel
does not have a definition for AllowHtmlString
You’re right. Xrlabel is meant for simple texts only. You should exchange Xrlabel for an Xrrichtext that is specifically designed to display formatted text in your reports. I edited the comment again. See if it fits you now
now yes, I switched the component and could send the string with html tags.
3
Formatting is only for organizing text, styles depends on the output you are using.
Whether it’s console is one thing, whether it’s file is another and depends on the format it needs, whether it’s printer depends on it and the technology used to generate printing, whether it’s web has to use HTML or do as the generator you’re using asks, whether it is GUI has to see how it does this in the technology used, varies whether it is Windows Forms, WPF, UWP, GTK, Xamarin iOS, Android, etc.
This code can be used so:
var frase = $"A data de hoje é: {DateTime.Now.Date}";
With the information of the technology used we can use so in XRRichText
:
seuLabel.Text = $"A data de hoje é: <b>{DateTime.Now.Date}</b>";
But if you want to use the label which is lighter (although all Devxpress components are not lightweight), it can do:
seuLabel.Font = new Font("nome da fonte", 11, FontStyle.Bold);
I put in the Github for future reference.
But you can’t make a part of the text in it label, can do in more than one placed side by side.
Documentations:
I will use in a devexpress xrLabel, in the Viewer report, I have several parameters in a string, but I need only one of them to be in bold
So you have to see in these technologies how to make something bold, in the manipulation of data you shouldn’t and you can’t do this. The documentation: https://documentation.devexpress.com/XtraReports/DevExpress.XtraReports.UI.XRLabel.members. Specifically, you must use the source: https://documentation.devexpress.com/XtraReports/DevExpress.XtraReports.UI.XRControl.Font.property. In this case, you must use the standard . NET: https://msdn.microsoft.com/en-us/library/system.drawing.font(v=vs.110). aspx, property Bold
: https://msdn.microsoft.com/en-us/library/system.drawing.font.bold(v=vs.110). aspx
the solution was to use another devexpress component, the xrRichText
. With it you can pass the string with html tags.
Browser other questions tagged c# .net string winforms textbox
You are not signed in. Login or sign up in order to post.
Where you will display this string?
– Ayrton Giffoni
@Ayrtongiffoni in a devexpress xrLabel
– Marceloawq