This is a migrated thread and some comments may be shown as answers.

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

4 Answers 64 Views
Buttons, RadioButton, CheckBox, etc
This is a migrated thread and some comments may be shown as answers.
erwin
Top achievements
Rank 1
Veteran
Iron
erwin asked on 05 Jul 2009, 04:22 PM
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

4 Answers, 1 is accepted

Sort by
0
Mike
Telerik team
answered on 06 Jul 2009, 02:17 PM
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.
0
erwin
Top achievements
Rank 1
Veteran
Iron
answered on 06 Jul 2009, 08:16 PM
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();  
 
            }  
 
0
Accepted
Mike
Telerik team
answered on 07 Jul 2009, 03:24 PM
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.
0
erwin
Top achievements
Rank 1
Veteran
Iron
answered on 08 Jul 2009, 04:08 PM
Mike,

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

Regards
Erwin
Tags
Buttons, RadioButton, CheckBox, etc
Asked by
erwin
Top achievements
Rank 1
Veteran
Iron
Answers by
Mike
Telerik team
erwin
Top achievements
Rank 1
Veteran
Iron
Share this question
or