Conditional Highlight Question
So, first let me say that Conditional Highlight is awesome!
I've been playing around with it over the last few days and love how I can use it to fine tune and change the look of a report based on the content that populates.
One question I had though might be an unusual use case (though it makes perfect sense to me).
I have a data band with 3 textboxes. I have two of the textboxes docked to the right and one docked to fill.
Under certain circumstances two of the textboxes could be empty.
Using the Conditional Highlight, I set the two textboxes that could be empty to not be visible when that is the case.
What strikes me as a bit odd is that when they aren't visible (as a result of the Conditional Highlight because they are empty), the textbox that is set to dock = fill doesn't fill the available space.
Has anyone else experienced this? Could it be a bug? The Conditional Highlight works correctly with everything else that I throw at it, but not this for some reason. I don't think it's an issue with the Conditional Highlight so much as the textbox's dock property, but I'm not sure to be honest.
Thoughts?
I've been playing around with it over the last few days and love how I can use it to fine tune and change the look of a report based on the content that populates.
One question I had though might be an unusual use case (though it makes perfect sense to me).
I have a data band with 3 textboxes. I have two of the textboxes docked to the right and one docked to fill.
Under certain circumstances two of the textboxes could be empty.
Using the Conditional Highlight, I set the two textboxes that could be empty to not be visible when that is the case.
What strikes me as a bit odd is that when they aren't visible (as a result of the Conditional Highlight because they are empty), the textbox that is set to dock = fill doesn't fill the available space.
Has anyone else experienced this? Could it be a bug? The Conditional Highlight works correctly with everything else that I throw at it, but not this for some reason. I don't think it's an issue with the Conditional Highlight so much as the textbox's dock property, but I'm not sure to be honest.
Thoughts?
Comments
welcome to the world of scripting [img]style_emoticons/<#EMO_DIR#>/biggrin.gif" style="vertical-align:middle" emoid=":D" border="0" alt="biggrin.gif" /> suppose you have 3 textboxes: 1. position = left 2. position = middle, with dock = full 3. position = right (data = Products.UnitsInStock , textobject name = Text9)[/img]
It appears that there is no way of setting a breakpoint or otherwise testing through the script to find out where the error may be (provided there is one)...
I tried your suggestion (Making changes to support the fields I have set) and it didn't change the width of the textbox.
private void Data3_BeforePrint(object sender, EventArgs e)
{
string value = (string)Report.GetColumnValue("Rooms.Items.Type");
if (value == "Note")
// set textobject position to the right edge of paper
ItemTitleTB.Bounds = new RectangleF(Units.Centimeters * 19f, 0, 0, 0);
else
// set textobject position to normal
ItemTitleTB.Bounds = new RectangleF(Units.Centimeters * 15.75f, 0, Units.Centimeters * 3.25f, Units.Centimeters * 0.5f);
}
Now, I thought perhaps because I have these controls set to dock that maybe the other controls weren't resizing to make room for this ItemTitleTB to stretch to fill the space.
So I tried this:
private void Data3_BeforePrint(object sender, EventArgs e)
{
//if (ItemQuantityTB.Visible == false && ItemUnitTB.Visible == false && ItemCostTB.Visible == false)
if (ItemQuantityTB.Text == "" && ItemUnitTB.Text == "" && ItemCostTB.Text == "")
{
ItemTitleTB.TextColor = Color.Gold; //Just to make clear that nothing was happening
ItemQuantityTB.Width = 0;
ItemUnitTB.Width = 0;
ItemCostTB.Width = 0;
ItemTitleTB.Width = 718.2F;
}
}
This also did not change the size of the text control (and presumably didn't change the size of the other controls that I want to be hidden either). In fact, it doesn't appear the event is firing.
I also tried using the AfterData event, but then read that BeforePrint occurs first, so it makes sense that that would be the one to use.
I also tried using the individual control's BeforePrint events, but that didn't resize either.
private void ItemQuantityTB_BeforePrint(object sender, EventArgs e)
{
if (ItemQuantityTB.Text == "")
{
float qtyWidth = ItemQuantityTB.Width;
ItemQuantityTB.Width = 0;
ItemTitleTB.Width += qtyWidth;
}
else
{
ItemQuantityTB.TextColor = Color.Green; //To test to see if the if was simply returning false.
}
}
Now, in this example, the ItemQuantityTB textboxes that had text in them, did turn green, but the textboxes did not resize if they were empty. I also tried setting the width to 0F.
I tried adding a border to the control if it was empty as well, but that did not happen.
Now, if I view or print the report, it doesn't work, but if I an previewing the report and click the "edit" button in the menu, it displays correctly in the editor at that point...
I also tried this:
private void ItemTitleTB_BeforePrint(object sender, EventArgs e)
{
if (((String)Report.GetColumnValue("Rooms.Items.Type")) == "Note")
{
ItemTitleTB.Width = 718.2F;
}
}
Trying to set the TitleTB to the width of the page if the TypeColumn was "Note", but this also did not work.
As you can see, I've been trying a lot of different things here to try to come up with a solution on my own. I also tried your suggestion. I completely understand your point that Visible doesn't mean it's "gone", but I figured by setting the width of these controls to 0, it would force the TitleTB to stretch... Or at least allow me to set the width myself.
I've also attached a picture with some dummy data to show what I am trying to do.
As you can see, the Quantity, Unit, and Cost are green currently because they have text in them (From the control's BeforePrint code above). I would like them to disapear or resize to 0 and allow the TitleTB to stretch when there is no Quantity, Unit, or Cost (the red text in the example).
I'm not sure what I'll try next (I'm out of ideas at the moment), but I will post back if I have any luck with it.
Thank you very much for your help!