Windows Develop Bookmark and Share   
 index > Windows Forms Designer > concetenate control in winform
 

concetenate control in winform

Hi all,

I'm developing a window-application. I found out a problem in design.

Ok , like this.

I have a field call

Tenant Name: TextBox1

Tenant Description : RichTextBox

Tenant Unit : TextBox2

My problem is with the RichTextBox. Because it is data entry which the description sometime is long , sometime is short, how do i "concatenate" the next line of control which is "Tenant Unit" always closer to the "Tenant Description" when the data is retrieved from database? Can you all understand what i want? hope so. :)




Terry_1314  Friday, June 12, 2009 4:02 AM
I too aggree with you - that's a lot of hassle. :)I toobelieve in simple and smart things. :)

And, making a good UI does not depend on coding a complex code but in smartly designing the GUI itself.
If you are ok,you cantry something like:

1. Put the Tenant Unit : TextBox2 beforeTenant Description : RichTextBox.
2. Put the Tenant Unit : TextBox2 and Tenant Name: TextBox1 side by side on top/before the Tenant Description : RichTextBox.
3. Have a fixed/ optimum size of the RichTextBox that would look better in most cases. And, have scrollbar in the richTextBox so that for long texts, User's can still view it comfortably.
Also, consistent GUI is good rather than - once a long RichTextBox and the nextt tile - a short one.

:)


Regards, Lakra :) - If the post is helpful or answers your question, please mark it as such.
Abhijeet Lakra  Friday, June 12, 2009 7:20 AM
As per my understanding- So, are are having problem when the text in the richTextBox is small.
And, you Area for RichTextBox has some empty space and then the textbox.

So, do you want to decrease the size of richTextBox aacoordingly for a small text?

Can you some some image(s) for better understanding?
Regards, Lakra :) - If the post is helpful or answers your question, please mark it as such.
Abhijeet Lakra  Friday, June 12, 2009 4:21 AM
Exactly. Any idea or solution? Your understanding is correct.
Terry_1314  Friday, June 12, 2009 4:22 AM
Are you sure- it the desired output you want to have? Because, itmay resize and relocatte your controls on the screen according to the changed height of the RichTextBox.

However- if you wish to do so..... :)

There would be some complex solutions to this.
But, I would give you a smart and robust solution.

Let me first define your problem in a simple way for better understanding:

You have a richTextBox of fixed Width. You want to vary the Height of RichTextBox depending on the length of Text. Right?

So, now on the same understanding, please find this method to resize you RichTextBox's height depending on text.

        /// <summary>
        /// Purpose: To adjust the height of a RichTextbox depending on the length of Text
        /// Logic: Use a Label-control for reference. 
        ///    Fix Label's MinumumSize, same as the width and height of the RichTextbox.
        ///    Fix Label's MaximumSize(Width), same as the width of the RichTextbox so that width does not increase.
        ///    Assign Label's MaximumSize(Height), to be far greater than the Height of RichTextbox.
        ///    Set Label's Text, same as Textbox's Text .
        ///    Now, the Label would resize itself because of AutoSize. 
        ///    So, set the height of RichTextbox same as of Label's.
        /// </summary>
        /// <param name="richTextBox1">RichTextbox whose height is to be adjusted.</param>
        private void ResizeRichTextBox(RichTextBox richTextBox1)
        {
            try
            {
                Label lblPrototype = new Label();

                lblPrototype.AutoSize = true;
                lblPrototype.Font = richTextBox1.Font;
                lblPrototype.BorderStyle = BorderStyle.FixedSingle;
                lblPrototype.MinimumSize = new Size(richTextBox1.Width, richTextBox1.Height);
                lblPrototype.MaximumSize = new Size(richTextBox1.Width, richTextBox1.Height * 10);
                lblPrototype.AutoSize = true;
                lblPrototype.Text = richTextBox1.Text;

                richTextBox1.Height = lblPrototype.PreferredHeight;
            }
            catch (Exception ex)
            {
                ex = new Exception("Error occurred while deciding vertical scroll for Textbox. " + ex.Message);
                throw ex;
            }
        }
Now, please do change the location of textBox and other controls below this RichTextBox.
As the height increases, it would cover the below controls.

You may need to calculate the correct Location from initial location and the height of the richTextBox now.
Or, you can think of some way to update the location of textBox etc below the richTextBox.
Or, you can dock the richTextBox and TextBox in a Panel.
Regards, Lakra :) - If the post is helpful or answers your question, please mark it as such.
Abhijeet Lakra  Friday, June 12, 2009 5:05 AM
opsss...that's alot of hassle. There must be a way to do this. Just i donno how. But your solution is definitely provide me some useful clue of doing it. It would be better there is other simpler way of doing it. I believe a lot of ppl also want to achieve this so that the UI will look nicer.
Terry_1314  Friday, June 12, 2009 5:11 AM
I too aggree with you - that's a lot of hassle. :)I toobelieve in simple and smart things. :)

And, making a good UI does not depend on coding a complex code but in smartly designing the GUI itself.
If you are ok,you cantry something like:

1. Put the Tenant Unit : TextBox2 beforeTenant Description : RichTextBox.
2. Put the Tenant Unit : TextBox2 and Tenant Name: TextBox1 side by side on top/before the Tenant Description : RichTextBox.
3. Have a fixed/ optimum size of the RichTextBox that would look better in most cases. And, have scrollbar in the richTextBox so that for long texts, User's can still view it comfortably.
Also, consistent GUI is good rather than - once a long RichTextBox and the nextt tile - a short one.

:)


Regards, Lakra :) - If the post is helpful or answers your question, please mark it as such.
Abhijeet Lakra  Friday, June 12, 2009 7:20 AM
hahaha. This is the solution i propose to client. But sadly, those client demand their own design. Those shitter. LOL..but is OK. I took this as challenge.

Thanks Lakra. :)
Terry_1314  Friday, June 12, 2009 7:47 AM

You can use google to search for other answers

Custom Search

More Threads

• control Event
• TYPE_E_LIBNOTREGISTERED
• help with usercontrol
• how can i close the main form without closing the application ?
• EditingControlShowing and DataGridViews with >1 ComboBoxes
• Dropping table from the datasource window does not behaves as expected
• XP Style Controls
• Error "Failed to create component 'AxHost'." when importing OCX control.
• Exception from HRESULT: Ox80040154(REGDB_E_CLASSNOTREG)????????
• DomainUpDown->SelectedIndex property not available in Forms Designer