Breaking Change in 2009 Q2: names of dynamically added controls must be uniqe

5 posts, 1 answers
  1. erwin
    erwin avatar
    358 posts
    Member since:
    Dec 2006

    Posted 05 Jul 2009 Link to this post

    Q2 throws an exception when I try to add 2 RadButtons with the same name to a RadPanel.Controls Collection.
    This was possible in Q1, had to add code to generate uniqe names.

    Not documented AFAIK. Please update your documentation with all the breaking changes introduced in 2009 Q2.

    Kind regards
    Erwin
  2. Mike
    Admin
    Mike avatar
    640 posts

    Posted 06 Jul 2009 Link to this post

    Hi Erwin,

    I can assure you that we have not changed the logic of adding Controls in RadPanel or any other RadControl. As a matter of fact, only the new RadDcok control and the related TabStripPanel implement logic that overrides the standard Control.ControlCollection. Can you please verify the issue you report is related to RadPanel? If so you will help us a lot if you can send us sample code to reproduce the issue.
    I am standing by for your response.

    Greetings,
    Mike
    the Telerik team

    Instantly find answers to your questions on the new Telerik Support Portal.
    Check out the tips for optimizing your support resource searches.
  3. UI for WinForms is Visual Studio 2017 Ready
  4. erwin
    erwin avatar
    358 posts
    Member since:
    Dec 2006

    Posted 06 Jul 2009 Link to this post

    I'm sorry, should have been RadForm insteat of RadPanel.
    I'm adding the buttons directly to a RadForm controls collection.

                foreach(....)  
                {  
                    RadButton btn = new RadButton();  
                    ((System.ComponentModel.ISupportInitialize)(btn)).BeginInit();  
     
                    // needed for 2009Q2:  
                    btn.Name = "linkButton" + i.ToString();  
     
                    btn.Text = info.Description;  
                    btn.TextAlignment = ContentAlignment.MiddleLeft;  
                    btn.ImageAlignment = ContentAlignment.MiddleLeft;  
                    btn.ButtonElement.ImagePrimitive.Margin = new Padding(5, 0, 0, 0);  
                    btn.Click += new EventHandler(btn_Click);  
                    topPosition += btn.Height;  
     
     
    ....  
     
                    this.Controls.Add(btn);  
                    i++;  
     
                    // needed for button to draw itself correctly  
                    ((System.ComponentModel.ISupportInitialize)(btn)).EndInit();  
     
                }  
     
  5. Answer
    Mike
    Admin
    Mike avatar
    640 posts

    Posted 07 Jul 2009 Link to this post

    Hello Еrwin,

    I tested your code against the latest RadForm version and I was unable to reproduce the problem.

    What we've changed regarding RadForm in Q2 is its designer. Now it resembles more the Document Designer of Windows.Forms.Form class. Does your code execute in context of VS designer? Does you form inherit from another RadForm?

    Otherwise I am not able to determine any other possible reason for this issue. RadForm relies on base (Form) Controls collection which does not contain any code related to the problem you are describing.
    I hope this information can help you determine what is causing this problem.

    If the problem persists please send us the complete source code of the form, along with description how you are using it and when the problem occurs.

    All the best,
    Mike
    the Telerik team

    Instantly find answers to your questions on the new Telerik Support Portal.
    Check out the tips for optimizing your support resource searches.
  6. erwin
    erwin avatar
    358 posts
    Member since:
    Dec 2006

    Posted 08 Jul 2009 Link to this post

    Mike,

    I can no longer reproduce the exception I got about the element being already in the collection.

    Regards
    Erwin
Back to Top
UI for WinForms is Visual Studio 2017 Ready