Move a component

Stimulsoft Reports.NET discussion
Post Reply
isoft
Posts: 55
Joined: Fri Sep 08, 2006 9:33 am
Location: Croatia

Move a component

Post by isoft »

Hi. Here's what I would need to do. I have a Text component in the GroupHeaderBand, which gets a number value from the database in the range of 1 to 7. Now, depending on that number, I need to move the other Text component also in that GroupHeaderBand to another position and to change the width of that component.
Is this possible? And also, I would need to put the code somewhere in the designer, i.e. in the GetValue event of the first Text component (or any other event).

Thank You very much for Your help!
Vital
Posts: 1278
Joined: Fri Jun 09, 2006 4:04 am

Move a component

Post by Vital »

You can change position of components in BeforePrintEvent of bands. Type following code in BeforePrintEvent of GroupHeaderBand:

Code: Select all

Text1.Left = DataSource.Index * 20;//You need use selected units 
Thank you.
isoft
Posts: 55
Joined: Fri Sep 08, 2006 9:33 am
Location: Croatia

Move a component

Post by isoft »

Thanks for the reply! It works great!
There's only one problem. I need to move the Text1 component based on the text value of the Text2 component. So, I putted this code in the BeforePrintEvent of the band:
If Text2.Text = "7" Then
Text1.Left = 2
End If

But, it's not working. Is this code ok, or?

Thanks very much for Your help! It was very important for me to do this as soon as possible or my boss would kill me!
Vital
Posts: 1278
Joined: Fri Jun 09, 2006 4:04 am

Move a component

Post by Vital »

Please use following code in GetValueEvent:

Code: Select all

StiText text = sender as StiText;
if (e.Value == "Owner")text.Left -= 1;
Thank you.
isoft
Posts: 55
Joined: Fri Sep 08, 2006 9:33 am
Location: Croatia

Move a component

Post by isoft »

Sorry, but I don't understand. In GetValue event of which Text component should I put this code? I need to move Text1 component based on the Text2 component's value, i.e. if Text2.Text = "7" Then Text1.Left = 2.

Thanks
isoft
Posts: 55
Joined: Fri Sep 08, 2006 9:33 am
Location: Croatia

Move a component

Post by isoft »

Hi.

I suceeded to do the thing that I needed, but I think I found a bug.
I put this code in GetValueEvent of Text2 component:

Code: Select all

If e.value = "7" Then
Text1.Left = 2
ElseIf e.Value = "5" Then
Text1.Left = 1
Both of the Text components (text1 and text2) are on the GroupHeaderBand.

But, when shown in the preview window, the Text1 component starts moving only in second group. In the first group, the Text1 component is not moved. Example:

First group
GroupHeaderCondition = "100"
Text2 = 7
Text1 => NOT MOVED

Second group
GroupHeaderCondition = "101"
Text2 = 7
Text1 => MOVED

Third group
GroupHeaderCondition = "102"
Text2 = 7
Text1 => MOVED

Fourth group
GroupHeaderCondition = "103"
Text2 = 5
Text1 => NOT MOVED

Fifth group
GroupHeaderCondition = "104"
Text2 = 5
Text1 => MOVED

Sixth group
GroupHeaderCondition = "105"
Text2 = 5
Text1 => MOVED

... and so on. I hope I was able to show what is going on. It seems that the code isn't applied on every GroupHeaderBand.

Do You maybe have a solution?
Thanks!





isoft
Posts: 55
Joined: Fri Sep 08, 2006 9:33 am
Location: Croatia

Move a component

Post by isoft »

I resolved the problem. I've used the code in the beforePrinting event of the groupheader, but instead of using the value from the Text component, I used the value from the datasource.

Thanks!
Vital
Posts: 1278
Joined: Fri Jun 09, 2006 4:04 am

Move a component

Post by Vital »

This is not bug. You need check order of component. In your case Text1 must have order position after Text2.

Thank you.
Post Reply