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

RadChildFrom Minimum Size

6 Answers 66 Views
Form
This is a migrated thread and some comments may be shown as answers.
Afaan
Top achievements
Rank 1
Afaan asked on 03 Nov 2008, 06:42 PM
Hello i am using several RadForms as child forms for an mdi. Part of this is letting the user decide the size of each RadForm by entering values in textboxes(height and width textboxes). I have tried to put the resizing of forms in the text changed events, but that does not seem to be working, as the radform seems to default to a different size before the user has a chance to enter the full value. Why is this? I have tried setting the minimum size of these radforms to be really small as well, but it still seems to default to some other values. On a seperate note, i had this functionality with the resizing in the Leave event of the textbox. However the problem with that is if the user has entered values for a child form, and clicks on a different child form, it resizes the new child form instead. All these child forms are being created at run time and i am using Winforms Q2 SP1 2008. A work around for either one of those cases would be good. Thanks in advance.

6 Answers, 1 is accepted

Sort by
0
John
Top achievements
Rank 1
answered on 04 Nov 2008, 04:31 PM
Hi Afaan,
    It sounds like you are accepting the user input as they type which is resizing the form before they can finish.  The easiest way to accomplish this is add an apply button and commit the new Height/Width values in that event.

Hope this helps,
John
0
Afaan
Top achievements
Rank 1
answered on 04 Nov 2008, 07:31 PM
Hello, i have considered adding an accept button, but the ideal case is to get the microsoft visual studio properties kind of feel, the way i already described. Thanks for the reply.
0
John
Top achievements
Rank 1
answered on 04 Nov 2008, 08:08 PM
I can understand not wanting to include an apply button.  So I created a project to replicate your setup with an MDIParent and two RadForms.  When I make a change to the form size it applies appropriately on Leave.  If you can attach a sample project this might help identify the problem you are experiencing.

Thanks,
John
0
Afaan
Top achievements
Rank 1
answered on 05 Nov 2008, 01:33 PM
Hi, thanks for your concern. How are you calling the child form in your scenario when resizing, using this.activemdichild? or by its name? I am using this.activemdichild in my project, since i have several instances being created at run time and can not call the child forms by name.  The problem occurs when you you leave, and click on another child form. I would like it to still resize the previously selected form, however since now the active form is different, it resizes the newly selected form. Here is the code for test project i created to better show what i mean.

public partial class Form1 : Telerik.WinControls.UI.ShapedForm     
    {     
        private Telerik.WinControls.RadForm test;     
    
        public Form1()     
        {     
            InitialzeComponent();     
        }     
    
        private void Form1_Load(object sender, EventArgs e)     
        {     
            for (int count = 0; count < 4; count++)     
            {     
                test = new Telerik.WinControls.RadForm();     
                test.Text=count.ToString();     
                test.MdiParent = this;     
                test.Enter += new EventHandler(test_Enter);     
                test.Show();     
            }     
        }     
    
        void test_Enter(object sender, EventArgs e)     
        {     
            textBox3.Text = this.ActiveMdiChild.Text;     
        }            
    
        private void textBox1_Leave(object sender, EventArgs e)     
        {     
            if (textBox1.Text != "" && Convert.ToInt32(textBox1.Text) > 0)     
            {     
                this.ActiveMdiChild.Width = Convert.ToInt32(textBox1.Text);     
            }     
        }     
    
        private void textBox2_Leave(object sender, EventArgs e)     
        {     
            if (textBox2.Text != "" && Convert.ToInt32(textBox2.Text) > 0)     
            {     
                this.ActiveMdiChild.Height = Convert.ToInt32(textBox2.Text);     
            }     
        }     
    }    
 
0
Accepted
John
Top achievements
Rank 1
answered on 05 Nov 2008, 03:07 PM
I see the problem.  So a way to accomplish what you are trying to do is to capture the ActiveMDIChild when you enter the text controls. See my changes below:

    public partial class Form1 : Telerik.WinControls.UI.ShapedForm  
    {  
        private Telerik.WinControls.RadForm test;  
 
        //placeholder to know which child you are working with  
        private Telerik.WinControls.RadForm activeChildForm;  
 
        public Form1()  
        {  
            InitializeComponent();  
            //setup event to capture entering both textbox1 and textbox2  
            textBox1.Enter += new EventHandler(textBoxSizes_Enter);  
        }  
 
        private void Form1_Load(object sender, EventArgs e)  
        {  
            for (int count = 0; count < 4; count++)  
            {  
                test = new Telerik.WinControls.RadForm();  
                test.Text = count.ToString();  
                test.MdiParent = this;  
                test.Enter += new EventHandler(test_Enter);  
                test.Show();  
            }  
        }  
 
        void test_Enter(object sender, EventArgs e)  
        {  
                         
        }  
 
        private void textBox1_Leave(object sender, EventArgs e)  
        {  
            if (textBox1.Text != "" && Convert.ToInt32(textBox1.Text) > 0)  
            {  
                activeChildForm.Width = Convert.ToInt32(textBox1.Text);  
            }  
        }  
 
        private void textBox2_Leave(object sender, EventArgs e)  
        {  
            if (textBox2.Text != "" && Convert.ToInt32(textBox2.Text) > 0)  
            {  
                activeChildForm.Height = Convert.ToInt32(textBox2.Text);  
            }  
        }  
 
        private void textBoxSizes_Enter(object sender, EventArgs e)  
        {  
            //caputure the active child so you apply settings correctly  
            activeChildForm = this.ActiveMdiChild as RadForm;  
        }  
    } 

You will want to ensure that activeChildForm is not null before doing the assignments.  Let me know if this doesn't help.

John
0
Afaan
Top achievements
Rank 1
answered on 05 Nov 2008, 04:08 PM
Thanks for the solution. It is much more reliable than my version as i had the active form captured in a string by title.
Tags
Form
Asked by
Afaan
Top achievements
Rank 1
Answers by
John
Top achievements
Rank 1
Afaan
Top achievements
Rank 1
Share this question
or