How to save dynamically created buttons

2 posts, 0 answers
  1. obi
    obi avatar
    3 posts
    Member since:
    Aug 2016

    Posted 10 Aug 2019 Link to this post

    I use the following code to create button dynamically. Please how can I save the button so that it will appear on next run? I have been looking for a solution and could not find one.

    Dim count As Integer = RadLayoutControl.Controls.OfType(Of Button).ToList.Count

    Dim button As Button = New Button

     button.Size = New System.Drawing.Size(RadSpinEditor1.Value, RadSpinEditor1.Value)
            button.Name = "btnDelete_" & (count + 1)
            button.Text = "test"

  2. Dess | Tech Support Engineer, Sr.
    Dess | Tech Support Engineer, Sr.  avatar
    3822 posts

    Posted 12 Aug 2019 Link to this post

    Hello, Obi, 

    All controls that are added at design time are stored in the Designer.cs file. This ensures that when you run the project and show the form, these controls will be loaded and shown as well. There is no automatic mechanism for storing the controls that you may add at run time. You need to implement such a custom functionality according to your custom requirements. You can iterate the controls you have and produce a custom XML file with the internal structure that you will store the information for restoring the controls back on the form when running the application.

    After some research in general programming forums, I have found the following threads which may be useful for serializing dynamics controls on the form:

    Note that most of the forum threads are reviewed by Telerik representatives and sometimes we address the questions asked by our customers in the forums as well. However, a post in the forum doesn't guarantee you a response from the Telerik support team. Moreover, threads are handled according to license and time of posting, so if it is an urgent problem, we suggest you use a support ticket, which would be handled before a forum thread.

    Thank you for your understanding.

    Dess | Tech Support Engineer, Sr.
    Progress Telerik
    Get quickly onboarded and successful with your Telerik and/or Kendo UI products with the Virtual Classroom free technical training, available to all active customers. Learn More.
Back to Top