Accessing report components from code in designer ?
Accessing report components from code in designer ?
Hi,
I looked trough the forums, demos & google, and still can't find the answer to my question, which is :
HOW to use the reports components from code, in the designer ?
I just would like to put code in some events, e.g. in the "beforeprint" event textboxA, have it set its value to "sum of textboxB + testboxC", but I can't manage to access thoses components.
I'm stuck with the error "A namespace does not directly contain members such as fields or methods".
I think the only thing I'd need to fix that would be to know the report instance name, but I couldn't find it. : (
Thanks in advance.
I looked trough the forums, demos & google, and still can't find the answer to my question, which is :
HOW to use the reports components from code, in the designer ?
I just would like to put code in some events, e.g. in the "beforeprint" event textboxA, have it set its value to "sum of textboxB + testboxC", but I can't manage to access thoses components.
I'm stuck with the error "A namespace does not directly contain members such as fields or methods".
I think the only thing I'd need to fix that would be to know the report instance name, but I couldn't find it. : (
Thanks in advance.
Accessing report components from code in designer ?
Hi Gobix,Gobix wrote:Hi,
I looked trough the forums, demos & google, and still can't find the answer to my question, which is :
HOW to use the reports components from code, in the designer ?
I just would like to put code in some events, e.g. in the "beforeprint" event textboxA, have it set its value to "sum of textboxB + testboxC", but I can't manage to access thoses components.
I'm stuck with the error "A namespace does not directly contain members such as fields or methods".
I think the only thing I'd need to fix that would be to know the report instance name, but I couldn't find it. : (
Thanks in advance.
were using this piece of code:
Dim db As Stimulsoft.Report.Components.StiDataBand
db = m_StiReport.GetComponentByName("DatenbandSerials")
now you can set
db.BeforePrint to code of your need.
Hope this helps
Stephan
Accessing report components from code in designer ?
Thanks for the quick answer, but I still can't manage to get rid of my errors.
Now, I get "invalid expression term" after 'Stimulsoft' , as well as "missing ';' after the 'AS' statement" (not at end on lines, I added thoses when I saw errors)
So, I replaced Stimulsoft.Report.Components.StiDataBand with StiDataBand, and now, I get "The name 'm_stiReport' doesn't exist in current context"
I also tried to dim a [S.R.C.]StiText, since I'm trying to work on textBoxes, but I got similar errors
What didn't I get in your answer ? I'm afraid I should replace "m_StiReport" with something else, but with what ?
(Sorry if I'm a bit newb, but I'm new to Stimulsoft Reports & never coded in C# before, only java & c++ :argh: )
Now, I get "invalid expression term" after 'Stimulsoft' , as well as "missing ';' after the 'AS' statement" (not at end on lines, I added thoses when I saw errors)
So, I replaced Stimulsoft.Report.Components.StiDataBand with StiDataBand, and now, I get "The name 'm_stiReport' doesn't exist in current context"
I also tried to dim a [S.R.C.]StiText, since I'm trying to work on textBoxes, but I got similar errors
What didn't I get in your answer ? I'm afraid I should replace "m_StiReport" with something else, but with what ?
(Sorry if I'm a bit newb, but I'm new to Stimulsoft Reports & never coded in C# before, only java & c++ :argh: )
Accessing report components from code in designer ?
Hi Gobix,
my code example was if your adding code from your application to the report. The Object m_StiReport was the name of my report object.
If you want to add code direct with the designer open thats very simple if i understand you right.
Choose component where you want the code to add. Like your textbox:
On the right Panel choose the "Flash Symbol" which is for the events.
Look down at the Print Events. Choose "Before Print"
Click "..." button and add your code there
Thats it.
Stephan
my code example was if your adding code from your application to the report. The Object m_StiReport was the name of my report object.
If you want to add code direct with the designer open thats very simple if i understand you right.
Choose component where you want the code to add. Like your textbox:
On the right Panel choose the "Flash Symbol" which is for the events.
Look down at the Print Events. Choose "Before Print"
Click "..." button and add your code there
Thats it.
Stephan
Accessing report components from code in designer ?
Right, thats my need, but the problem I get is I can't find how to access to the components : I don't know their names !
Of course, I know my textboxes are "textbox42" and so, but I don't know the name of the report, so when I put code like "textbox42.enabled = false" or textBox01.value = concat(textBox02.value, textBox02.value);, I get errors stating that no such component exists in current context !
I'm pretty sure that the only thing I need is the Report's name.
Of course, I know my textboxes are "textbox42" and so, but I don't know the name of the report, so when I put code like "textbox42.enabled = false" or textBox01.value = concat(textBox02.value, textBox02.value);, I get errors stating that no such component exists in current context !
I'm pretty sure that the only thing I need is the Report's name.
Accessing report components from code in designer ?
Hi Gobix,
Please set all values in all textboxes of the DataBand in the BeforePrint event for each record
Text1.TextValue = "my value1";
Text2.TextValue = "my value2";
Text3.TextValue = Text1.TextValue + Text2.TextValue ;
If it is not inside of one band, please use variables as a workaround.
Thank you.
Please set all values in all textboxes of the DataBand in the BeforePrint event for each record
Text1.TextValue = "my value1";
Text2.TextValue = "my value2";
Text3.TextValue = Text1.TextValue + Text2.TextValue ;
If it is not inside of one band, please use variables as a workaround.
Thank you.
Accessing report components from code in designer ?
Thanks to your reply, I managed to clean every error and get something working ! I had several troubles, including wrong case 
(Just a suggestion, but when editing an event's code, having the report's items in the outline (in addition to data src, vars, sys vars, functions & formatting) could be handy.)
Tough, I still can't read the boxes values :
If I affect a box (e.g. Text1.TextValue = "my value1";), it works fine
But if I want to affect another one with existing values (e.g. Text3.TextValue = Text1.TextValue + Text2.TextValue;), I only get an empty box.
I tried to use GetValue(), but in vain.
Do I have to set every box manually via the event if I want to access their values, or is there a way to get thoses ?
Also, the first thing I'm trying to do is a page total (in a group), I implemented it with a running total that I try to manually reset on every page, but, I can't figure out how to access to its current value, so I'm stuck.
Thanks for your help.

(Just a suggestion, but when editing an event's code, having the report's items in the outline (in addition to data src, vars, sys vars, functions & formatting) could be handy.)
Tough, I still can't read the boxes values :
If I affect a box (e.g. Text1.TextValue = "my value1";), it works fine
But if I want to affect another one with existing values (e.g. Text3.TextValue = Text1.TextValue + Text2.TextValue;), I only get an empty box.
I tried to use GetValue(), but in vain.
Do I have to set every box manually via the event if I want to access their values, or is there a way to get thoses ?
Also, the first thing I'm trying to do is a page total (in a group), I implemented it with a running total that I try to manually reset on every page, but, I can't figure out how to access to its current value, so I'm stuck.
Thanks for your help.
Accessing report components from code in designer ?
Hi Gobix,
Please try the technique from the following topic:
http://forum.stimulsoft.com/Default.aspx?g=posts&t=2204
The following assigning will work only inside of one band when you set all textboxes in the BeforePrint event of that band.
Text3.TextValue = Text1.TextValue + Text2.TextValue
So what would work is that only:
Text1.TextValue = "1";
Text2.TextValue = "2";
Text3.TextValue = Text2.TextValue + Text1.TextValue;
Thank you.
Please try the technique from the following topic:
http://forum.stimulsoft.com/Default.aspx?g=posts&t=2204
The following assigning will work only inside of one band when you set all textboxes in the BeforePrint event of that band.
Text3.TextValue = Text1.TextValue + Text2.TextValue
So what would work is that only:
Text1.TextValue = "1";
Text2.TextValue = "2";
Text3.TextValue = Text2.TextValue + Text1.TextValue;
Thank you.
Accessing report components from code in designer ?
Hi,
I already use such technique to reset totals, but it does only work on every new group item, I would like to reset my total on every new page (I got group items which take more than 1 page).
(Also, sum seems to work correctly in group, I didn't understand what is supposed not to work)
To reset my total, here are some ways I tried :
-Currently, I have an event in my beforePrint data band, which sums each entry value to a dictionnary variable, and I reset this value to zero each time my page header is print. Alas, it seems that several headers are print at the same time, because nothing is reset between my 2 pages of the same group item.
-Manually reset the value of my box with the running total on new pages, but I don't even know if I can access this value. Anyway, the "new page" event would probably execute at a wrong time, like with my current, not-working, 'solution'.
-Set "report.onNewPage" event, if it did exist.
About textBoxes values concatenation, well.. I understant what you say, but is there no way to access the current value of boxes with formulas like "running total" ? Sounds quite weird to me.
Thanks for your time.
I already use such technique to reset totals, but it does only work on every new group item, I would like to reset my total on every new page (I got group items which take more than 1 page).
(Also, sum seems to work correctly in group, I didn't understand what is supposed not to work)
To reset my total, here are some ways I tried :
-Currently, I have an event in my beforePrint data band, which sums each entry value to a dictionnary variable, and I reset this value to zero each time my page header is print. Alas, it seems that several headers are print at the same time, because nothing is reset between my 2 pages of the same group item.
-Manually reset the value of my box with the running total on new pages, but I don't even know if I can access this value. Anyway, the "new page" event would probably execute at a wrong time, like with my current, not-working, 'solution'.
-Set "report.onNewPage" event, if it did exist.
About textBoxes values concatenation, well.. I understant what you say, but is there no way to access the current value of boxes with formulas like "running total" ? Sounds quite weird to me.
Thanks for your time.
Accessing report components from code in designer ?
Hi Gobix,
Could you please prepare a test project which illustrates the problems you describe and to send it to support[at]stimulsoft.com for analysis?
Thank you.
Could you please prepare a test project which illustrates the problems you describe and to send it to support[at]stimulsoft.com for analysis?
Thank you.