SetChildIndex in ControlAdded Event

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I have a user control from a 3rd party that I want to make sure is at the 0
index of my form's Controls ControlCollection. To accomplish this I've tried
catching the ControlAdded event from the Controls object and then if the
control being added is of the right type, i do a:

Controls.SetChildIndex(e.Control, 0);

this does move the control to the 0 index after the call, but at some point
after this, the form is moving it to the end of the collection. How can I
ensure that the control is in the 0 index?

(Also I can't make the call to SetChildIndex after calling Form.Add(control)
because the control adds and removes itseslf from the collection based on
it's state)
 
Hi,

First of all, I would like to confirm my understanding of your issue. From
your description, I understand that the index of the control in the
controls collection changes after you have set it to 0. If there is any
misunderstanding, please feel free to let me know.

I tried to set the index of a TextBox on my machine, and it works well. The
index will not be changed after other operations. In this case, I suggest
you try to following:

1. Use a windows form control in .NET framework, for example, a TextBox to
replace the 3rd party control to see if it is the 3rd party control issue.
2. If TextBox still has such problems, can you give me a code snippet that
can repro this issue?

HTH.

Kevin Yu
=======
"This posting is provided "AS IS" with no warranties, and confers no
rights."
 
Back
Top