bugDotGNU Portable.NET - Bugs: bug #10394, Control.cs Add(..) does not show...

 
 

You are not allowed to post comments on this tracker with your current authentication level.

bug #10394: Control.cs Add(..) does not show the control if the control initially was removed

Submitter:  Heiko Weiss <brubbel>
Submitted:  Wed 15 Sep 2004 10:54:17 AM UTC
   
 
Category:  None Severity:  3 - Normal
Item Group:  None Status:  Fixed
Privacy:  Public Assigned to:  None
Open/Closed:  Closed

Mon 22 Nov 2004 02:09:35 PM UTC, comment #3: 

works in current cvs.

Klaus Treichel <ktreichel>
Group administrator
Tue 05 Oct 2004 04:05:34 PM UTC, comment #2: 

Seems to work ok, on the CVS build.

Gopal.V <t3rmin4t0r>
Group administrator
Tue 05 Oct 2004 01:31:00 PM UTC, comment #1: 

I added a sample

Heiko Weiss <brubbel>
Group Member
Wed 15 Sep 2004 10:54:17 AM UTC, original submission:  

- create a form FF
- in this form you have a Control XX
- remove the control XX from the forms FF Controls collection in the contructure of the form FF
- some time after (e.g. Button Click) add the Control XX to the forms FF Controls collection by this.Controls.Add( XX )

-> the Control XX is not created correctly and is not been displayed

I have made a quick hack in Control.cs:
...
  // Add a control to this collection.
  public virtual void Add(Control value)
    {
     if(value != null)
     {
      if(value.Parent == owner)
      {
       // We are already under this owner, so merely
       // send it to the back of its sibling stack.
       value.SendToBack();
      }
      else
      {
       // Suspend layout on the parent while we do this.
       owner.SuspendLayout();
       try
       {
        // Change the parent to the new owner.
        value.Parent = owner;

        // Assign the next tab order if the control doesnt have one.
        if (value.tabIndex == -1)
        {
         int lastIndex = 0;
         for (int i = 0; i < owner.numChildren; i++)
         {
          int index = owner.children[i].TabIndex;
          if (lastIndex <= index)
           lastIndex = index + 1;
         }
         value.tabIndex = lastIndex;
        }

        // Initialize layout within the new context.
        value.InitLayout();
       }
       finally
       {
        // Resume layout, but don't perform it yet.
        owner.ResumeLayout(false);
       }

       // Now perform layout on the control if necessary.
       if ( true /* Heiko Weiss: always create control owner.IsHandleCreated && value.Visible */ )
       {
        // Make sure the control exists.
        value.CreateControl();
        owner.PerformLayout(value, "Parent");
       }
       // Notify the owner that the control was added.
       owner.OnControlAdded
        (new ControlEventArgs(value));
      }
     }
    }
...


Heiko Weiss <brubbel>
Group Member

 

(Note: upload size limit is set to 16384 kB, after insertion of the required escape characters.)

Attached Files
file #1832:  Control.cs.zip added by brubbel (22KiB - application/x-zip-compressed - Sample)

 

Depends on the following items: None found

Items that depend on this one: None found

 

CC list is empty

 

There are 0 votes so far. Votes easily highlight which items people would like to see resolved in priority, independently of the priority of the item set by tracker managers.

 

Follow 3 latest changes.

Date Changed by Updated Field Previous Value => Replaced by
2004-11-22 ktreichel StatusNone Fixed
    Open/ClosedOpen Closed
2004-10-05 brubbel Attached File- Added Control.cs.zip, #1733

Back to the top

Powered by Savane 3.15-94dd.
Corresponding source code