enumerate the contols of a form

edited May 2013 in FastReport .NET
I want to access to several controls of a form in a function . You can do that in C# :
foreach( Control ctrl in this.Controls )
 {
 if ( ctrl.Name == name ) // Ou Tag.
 return ctrl;}
but in fastreport I have this error message :

"Impossible d'effectuer un cast d'un objet de type 'FastReport.Dialog.ButtonControl' en type 'System.Windows.Forms.Control'."

How can I do the same in fastreport

thank you

Comments

  • edited 1:18AM
    Did you ever figure this out? I am trying to do the same thing...
    oliv wrote: »
    I want to access to several controls of a form in a function . You can do that in C# :
    foreach( Control ctrl in this.Controls )
     {
     if ( ctrl.Name == name ) // Ou Tag.
     return ctrl;}
    
    but in fastreport I have this error message :

    "Impossible d'effectuer un cast d'un objet de type 'FastReport.Dialog.ButtonControl' en type 'System.Windows.Forms.Control'."

    How can I do the same in fastreport

    thank you
  • edited 1:18AM
    So I figured this out on my own.... here is the code to do this in VB
    for each o as object in Report.AllObjects
            if typeof(o) is TextObject then 
                 dim txt as TextObject = directcast(o,TextObject)
                 'Now do what you want with txt
            end if
    next
    

Leave a Comment