PC Review


Reply
Thread Tools Rate Thread

Add control ontop of another control

 
 
PeterB
Guest
Posts: n/a
 
      30th Nov 2004
Hi!

If I have a combobox on a form, I then create a textbox which takes the
combobox as an argument. The textbox uses the location and size of the
combobox to define it's postion on the form. However, I am unable to get the
textbox to be ontop of the combobox... This should be really simple but I
just can't find the way to do it.. I can see the textbox behind the
combobox...

BringToFront() doesn't work.

regards,

Peter


 
Reply With Quote
 
 
 
 
Peter Foot [MVP]
Guest
Posts: n/a
 
      30th Nov 2004
You should be able to call SetChildIndex on the ControlCollection of the
form or container control on which these controls reside. e.g.

Me.Controls.SetChildIndex(textBox1, 0);

The z-order of the controls should be affected by their order in the
controls collection - with 0 being the foremost control. By default new
controls are added to the end of the collection and the back of the z-order

Peter

--
Peter Foot
Windows Embedded MVP
www.inthehand.com | www.opennetcf.org

"PeterB" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> Hi!
>
> If I have a combobox on a form, I then create a textbox which takes the
> combobox as an argument. The textbox uses the location and size of the
> combobox to define it's postion on the form. However, I am unable to get
> the textbox to be ontop of the combobox... This should be really simple
> but I just can't find the way to do it.. I can see the textbox behind the
> combobox...
>
> BringToFront() doesn't work.
>
> regards,
>
> Peter
>



 
Reply With Quote
 
PeterB
Guest
Posts: n/a
 
      1st Dec 2004
Thanks Peter, that's exactly what I need. I am doing it like this, could
that cause any unexpected behaviour?

this = the textbox, so the code is run in the textbox's constructor.
// Add this instance to the same parent as the combobox

int iCmbIndx = this.Parent.Controls.GetChildIndex( cmb );

int iTxtIndx = this.Parent.Controls.GetChildIndex( this );

if( iCmbIndx < iTxtIndx )

{

this.Parent.Controls.SetChildIndex(this, iCmbIndx);

this.Parent.Controls.SetChildIndex(cmb, iTxtIndx);

}



"Peter Foot [MVP]" <(E-Mail Removed)> skrev i meddelandet
news:(E-Mail Removed)...
> You should be able to call SetChildIndex on the ControlCollection of the
> form or container control on which these controls reside. e.g.
>
> Me.Controls.SetChildIndex(textBox1, 0);
>
> The z-order of the controls should be affected by their order in the
> controls collection - with 0 being the foremost control. By default new
> controls are added to the end of the collection and the back of the
> z-order
>
> Peter
>
> --
> Peter Foot
> Windows Embedded MVP
> www.inthehand.com | www.opennetcf.org
>
> "PeterB" <(E-Mail Removed)> wrote in message
> news:(E-Mail Removed)...
>> Hi!
>>
>> If I have a combobox on a form, I then create a textbox which takes the
>> combobox as an argument. The textbox uses the location and size of the
>> combobox to define it's postion on the form. However, I am unable to get
>> the textbox to be ontop of the combobox... This should be really simple
>> but I just can't find the way to do it.. I can see the textbox behind the
>> combobox...
>>
>> BringToFront() doesn't work.
>>
>> regards,
>>
>> Peter
>>

>
>



 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Use Pocket PC to control your Media Player computer -- PPC Tablet Remote Control Suite 2.0 HL Microsoft Windows 2000 Multimedia 0 14th Dec 2004 03:17 AM
Compile errors when using form control's "Control Source" property to refer to the control's value Yarik Mezheritskiy Microsoft Access Form Coding 3 5th Nov 2004 01:56 AM
Showing 1 control inside a 2nd control where the 2nd control is a derived control. malcolm Microsoft Dot NET Framework Forms 0 10th Jun 2004 10:29 PM
Combo Box Control - CONTROL tab missing from FORMAT CONTROL dialogue =?Utf-8?B?QWw=?= Microsoft Excel Worksheet Functions 1 11th Mar 2004 06:47 PM
Using Table control in a custom composite control. Control does not render properly in design time. jb_in_marietta@yahoo.com Microsoft ASP .NET 0 1st Jul 2003 10:26 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 11:39 PM.