Programatically assigning BackColor for TextBox

Stimulsoft Reports.UWP discussion
Vamshi
Posts: 9
Joined: Mon May 25, 2015 11:41 am

Programatically assigning BackColor for TextBox

Post by Vamshi »

Hi,
Based on the collection values(color codes) TextBox back color has to be changed programmatically where as textbox has been placed in DataBand in the respective .mrt file.

Kindly help me on this.
Alex K.
Posts: 6488
Joined: Thu Jul 29, 2010 2:37 am

Re: Programatically assigning BackColor for TextBox

Post by Alex K. »

Hello,

Sorry, maybe we did not exactly understand your question. Could you explain your issue in more details?

Thank you.
Vamshi
Posts: 9
Joined: Mon May 25, 2015 11:41 am

Re: Programatically assigning BackColor for TextBox

Post by Vamshi »

Hi Aleksey,
We had a requirement for changing the background color of the Textbox which is placed in a DataBand dynamically. The Color code values are available in the collection binded to the DataBand.

Kindly help me on this.
HighAley
Posts: 8430
Joined: Wed Jun 08, 2011 7:40 am
Location: Stimulsoft Office

Re: Programatically assigning BackColor for TextBox

Post by HighAley »

Hello.

You could use Conditions to set background color.

Thank you.
Vamshi
Posts: 9
Joined: Mon May 25, 2015 11:41 am

Re: Programatically assigning BackColor for TextBox

Post by Vamshi »

Hi Aleksey Andreyanov,

Thanks for your quick response. But I need help on the issue i.e. The color of the text is not based on the any condition, even though this conditions can be set at the time .mrt design face only while designing the report. But in my scenario, The background color of the text box has to be changed based on my collection, the collection has the color name property as a string. User selects the colors dynamically on the UI, based on that user selections these collection will be made. Now I need the help that based on this collection, text box background color has to be changed while generating the report.

Thank you.
HighAley
Posts: 8430
Joined: Wed Jun 08, 2011 7:40 am
Location: Stimulsoft Office

Re: Programatically assigning BackColor for TextBox

Post by HighAley »

Hello.

As a way you could try to use next code:

Code: Select all

var comp = report.GetComponentByName("Text1");
(comp as StiText).Brush = new StiSolidBrush(System.Drawing.Color.FromArgb(255, 0, 150, 148));
Thank you.
Vamshi
Posts: 9
Joined: Mon May 25, 2015 11:41 am

Re: Programatically assigning BackColor for TextBox

Post by Vamshi »

Hi Aleksey Andreyanov,
Thanks for your Reply. The above given solution works fine if my textbox is outside the DataBand. But my textbox is inside the DataBand. So all TextBoxes inside the DataBand are filled with the last color in the collection. Also I have attached the generated pdf file for your reference.

Thankyou.
Attachments
Stimulsoft Report.pdf
Generated Report
(1.22 MiB) Downloaded 653 times
HighAley
Posts: 8430
Joined: Wed Jun 08, 2011 7:40 am
Location: Stimulsoft Office

Re: Programatically assigning BackColor for TextBox

Post by HighAley »

Hello.

Where do you get colors?
Do you have the fixed amount of colors?

Thank you.
Vamshi
Posts: 9
Joined: Mon May 25, 2015 11:41 am

Re: Programatically assigning BackColor for TextBox

Post by Vamshi »

Hi,

These colors are getting from the UI when User selects color in color pallete.
No fixed amount of colors. Those are dynamic which can be less number of more number
HighAley
Posts: 8430
Joined: Wed Jun 08, 2011 7:40 am
Location: Stimulsoft Office

Re: Programatically assigning BackColor for TextBox

Post by HighAley »

Hello.

Maybe the easiest solution will be to add Conditions from code?
Try to use next code to add Conditions:

Code: Select all

var txtColValue = report.GetComponentBy Name("Text1");
 StiCondition highlightcond = new StiCondition();
highlightcond.DataType = StiFilterDataType.Numeric;
highlightcond.TextColor = Color.Red;
highlightcond.Column = "{dt." + ColumnName + "}";
highlightcond.Condition = StiFilterCondition.EqualTo;
highlightcond.Value1 = "1";
highlightcond.Font = new System.Drawing.Font("Calibri", 10F, System.Drawing.FontStyle.Bold);
highlightcond.BackColor = Color.Beige;
highlightcond.Enabled = true;
txtColValue.Conditions.Add(highlightcond); 
Thank you.
Locked