Page Index Toggle Pages: 1 Send TopicPrint
Normal Topic InPlaceEditing - Box resizing (Read 1603 times)
David Long
Full Member
***
Offline


I love YaBB 1G - SP1!

Posts: 136
Location: England
Joined: Oct 23rd, 2006
InPlaceEditing - Box resizing
Dec 18th, 2006 at 2:30pm
Print Post  
When a user finishes editing the contents of a box I resize the box by using:

           box.FitSizeToText(FitSize.KeepWidth);

Is there any way of resizing the box as the user types.  The event I'm looking for (Box Contents Changing event) does not seem to be available.

Thanks,
DavidL
  
Back to top
 
IP Logged
 
Stoyo
God Member
*****
Offline


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: InPlaceEditing - Box resizing
Reply #1 - Dec 18th, 2006 at 5:48pm
Print Post  
You can handle the TextBox.TextChanged event to resize the box as the user types.

Code
Select All
Box currentBox;
TextBox textBox;

private void fc_EnterInplaceEditMode(object sender, MindFusion.Diagramming.WinForms.InplaceEditArgs e)
{
   currentBox = e.Node as Box;
   textBox = e.TextBox;
   textBox.SelectionStart = e.TextBox.Text.Length;
   textBox.TextChanged += new EventHandler(TextBox_TextChanged);
}

private void TextBox_TextChanged(object sender, EventArgs e)
{
   Box temp = new Box(fc);
   RectangleF rect = currentBox.BoundingRect;
   rect.Inflate(10, 10);
   temp.BoundingRect = rect;
   temp.Text = textBox.Text;

   temp.FitSizeToText(FitSize.KeepRatio);
   currentBox.BoundingRect = temp.BoundingRect;

   Rectangle clientRect = fc.DocToClient(temp.BoundingRect);
   textBox.Location = clientRect.Location;
   textBox.Size = clientRect.Size;
}
 



Stoyan
  
Back to top
 
IP Logged
 
David Long
Full Member
***
Offline


I love YaBB 1G - SP1!

Posts: 136
Location: England
Joined: Oct 23rd, 2006
Re: InPlaceEditing - Box resizing
Reply #2 - Dec 20th, 2006 at 9:30am
Print Post  
Thanks, that saved a lot of thinking!
Had to remove the line:

  rect.Inflate(10, 10);

for it to work perfectly.
DavidL
  
Back to top
 
IP Logged
 
Page Index Toggle Pages: 1
Send TopicPrint