How to change fonts depending on data
Posted: Tue Mar 27, 2007 11:33 am
Hi, I'm new to this tool (and still evaluating) and i need a few things more before making a final recommendation.
What is left unanswered for now is :
1- We need to be able to custom the fonts of our data depending of it's value. Probably something like putting ~S~ before a value we want to have as struckout in the report and ~U~ before a value we want as underlined.
I now need to understand how i can scan my values for ~S~ and ~U~, change the field font and remove ~S~ ~U~ from the value for each value.
the code from another tool looked like this :
private void MyReport_PrintSection(object sender, C1.Win.C1Report.ReportEventArgs e)
{
if (e.Section == SectionTypeEnum.Detail)
{
foreach (Field f in _c1r.Sections[SectionTypeEnum.Detail].Fields)
{
if (f.Value.ToString().IndexOf('~') != -1)
{
string fvalue = f.Value.ToString();
int start = fvalue.IndexOf('~');
int end = fvalue.IndexOf('~', start+1);
string code = fvalue.Substring(start+1, end-start-1);
f.Value = fvalue.Substring(end+1);
if(code == "S" || code == "s")
f.Font = new Font(f.Font, System.Drawing.FontStyle.Strikeout);
else if(code == "U" || code == "u")
f.Font = new Font(f.Font, System.Drawing.FontStyle.Underline);
}
}
}
}
2- We will be using images from our ressource files and using and xml from memory instead of from a file, could that be an issue ?
And i think that's about it. For now, this tool looks like the best in the market to me
Sacha
What is left unanswered for now is :
1- We need to be able to custom the fonts of our data depending of it's value. Probably something like putting ~S~ before a value we want to have as struckout in the report and ~U~ before a value we want as underlined.
I now need to understand how i can scan my values for ~S~ and ~U~, change the field font and remove ~S~ ~U~ from the value for each value.
the code from another tool looked like this :
private void MyReport_PrintSection(object sender, C1.Win.C1Report.ReportEventArgs e)
{
if (e.Section == SectionTypeEnum.Detail)
{
foreach (Field f in _c1r.Sections[SectionTypeEnum.Detail].Fields)
{
if (f.Value.ToString().IndexOf('~') != -1)
{
string fvalue = f.Value.ToString();
int start = fvalue.IndexOf('~');
int end = fvalue.IndexOf('~', start+1);
string code = fvalue.Substring(start+1, end-start-1);
f.Value = fvalue.Substring(end+1);
if(code == "S" || code == "s")
f.Font = new Font(f.Font, System.Drawing.FontStyle.Strikeout);
else if(code == "U" || code == "u")
f.Font = new Font(f.Font, System.Drawing.FontStyle.Underline);
}
}
}
}
2- We will be using images from our ressource files and using and xml from memory instead of from a file, could that be an issue ?
And i think that's about it. For now, this tool looks like the best in the market to me

Sacha