locked
Problem adding removing controls RRS feed

  • Question

  • I add controls dinamically to panel, i add a groupbox with X spineditors (all dinamically), when i clear the groupbox dont work propertly, example in images

    1-clik to add this controls

    at first time this controll added propertly, first button click, add this groupbox with 3 spineditor and one checkbox

    2- click to remove previous control and add news

    all is correct at this moment, but....

    3- add again the first controls

    note the 60.000 will be 60 withought decimal places


    • Edited by legolas2024 Wednesday, February 3, 2016 8:44 AM
    Wednesday, February 3, 2016 8:43 AM

Answers

  • Hi legolas2024,

    What's your issue? In your screenshots, I haven't found something wrong with add or remove control.

    >> note the 60.000 will be 60 withought decimal places

    I couldn't understand your descript, would you provide more detail of this?

    If your issue is about add and remove controls, maybe you could try the following code:

          
      private CheckBox cbMain = new CheckBox();
    
            private void btnAdd_Click(object sender, EventArgs e)
    
            {
    
                if (!gbMain.Controls.Contains(cbMain))
    
                    this.gbMain.Controls.Add(cbMain);
    
            }
    
            private void btnRemove_Click(object sender, EventArgs e)
    
            {
    
                if (gbMain.Controls.Contains(cbMain))
    
                    this.gbMain.Controls.Remove(cbMain);
    
            }
    
            private void Form3_Load(object sender, EventArgs e)
    
            {
    
                cbMain.Text = "test";
    
                cbMain.Location = new Point((gbMain.Width - cbMain.Width) / 2, (gbMain.Height - cbMain.Height) / 2);
    
            }
    

    If you want add and remove control many times, you could use a variable to store the control.

    If your issue is about devexpress tools, you could get better support at devexpress forum.

    Regards,

    Moonlight


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.


    Thursday, February 4, 2016 6:44 AM

All replies

  • Note: i dont create new controls, only clear/add
    Wednesday, February 3, 2016 8:48 AM
  • Hi legolas2024,

    What's your issue? In your screenshots, I haven't found something wrong with add or remove control.

    >> note the 60.000 will be 60 withought decimal places

    I couldn't understand your descript, would you provide more detail of this?

    If your issue is about add and remove controls, maybe you could try the following code:

          
      private CheckBox cbMain = new CheckBox();
    
            private void btnAdd_Click(object sender, EventArgs e)
    
            {
    
                if (!gbMain.Controls.Contains(cbMain))
    
                    this.gbMain.Controls.Add(cbMain);
    
            }
    
            private void btnRemove_Click(object sender, EventArgs e)
    
            {
    
                if (gbMain.Controls.Contains(cbMain))
    
                    this.gbMain.Controls.Remove(cbMain);
    
            }
    
            private void Form3_Load(object sender, EventArgs e)
    
            {
    
                cbMain.Text = "test";
    
                cbMain.Location = new Point((gbMain.Width - cbMain.Width) / 2, (gbMain.Height - cbMain.Height) / 2);
    
            }
    

    If you want add and remove control many times, you could use a variable to store the control.

    If your issue is about devexpress tools, you could get better support at devexpress forum.

    Regards,

    Moonlight


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.


    Thursday, February 4, 2016 6:44 AM