Hi I have a TabControl object that I need to insert new TabPages into. To
append them to the end of the Controls Collection I can do:
tc.controls.add (tp)
(tc - tabcontrol object)
(tp - tabpage object)
But how can I insert them into the middle of collection? I see a 'RemoveAt'
method that takes an index to remove at a specific location, how come
there's not an 'AddAt' or 'Insert' method?
This seems like something that would be quite common for anyone working with
TabControls (or any type of Control Collection for that matter). What am I
missing here? 7 6259
You can use Insert(int index, object item). If we are referring to an
ArrayList or CollectionBase it will automatically resize the collection
for you.
HTH
Erick Sgarbi www.blog.csharpbox.com
"Mark Denardo" <ma*********@ru nbox.com> wrote in message
news:z9******** ************@co mcast.com: Hi I have a TabControl object that I need to insert new TabPages into. To append them to the end of the Controls Collection I can do:
tc.controls.add (tp)
(tc - tabcontrol object) (tp - tabpage object)
But how can I insert them into the middle of collection? I see a 'RemoveAt' method that takes an index to remove at a specific location, how come there's not an 'AddAt' or 'Insert' method?
This seems like something that would be quite common for anyone working with TabControls (or any type of Control Collection for that matter). What am I missing here?
You'll have to show me an example, because:
tc.controls.ins ert(3, tp) gives me:
- 'Insert' is not a member of
'System.Windows .Forms.Control. ControlCollecti on'.
And tc.Insert(3, tp) gives me:
- 'System.Windows .Forms.TabContr ol.Private Sub Insert(index As Integer,
tabPage As System.Windows. Forms.TabPage)' is not accessible in this context
because it is 'Private'.
"Erick" <no***********@ csharbox.com> wrote in message
news:O8******** ******@tk2msftn gp13.phx.gbl... You can use Insert(int index, object item). If we are referring to an ArrayList or CollectionBase it will automatically resize the collection for you.
HTH Erick Sgarbi www.blog.csharpbox.com "Mark Denardo" <ma*********@ru nbox.com> wrote in message news:z9******** ************@co mcast.com:
Hi I have a TabControl object that I need to insert new TabPages into. To append them to the end of the Controls Collection I can do:
tc.controls.add (tp)
(tc - tabcontrol object) (tp - tabpage object)
But how can I insert them into the middle of collection? I see a 'RemoveAt' method that takes an index to remove at a specific location, how come there's not an 'AddAt' or 'Insert' method?
This seems like something that would be quite common for anyone working with TabControls (or any type of Control Collection for that matter). What am I missing here?
Mark Denardo wrote: You'll have to show me an example, because:
tc.controls.ins ert(3, tp) gives me:
- 'Insert' is not a member of 'System.Windows .Forms.Control. ControlCollecti on'.
And tc.Insert(3, tp) gives me:
- 'System.Windows .Forms.TabContr ol.Private Sub Insert(index As Integer, tabPage As System.Windows. Forms.TabPage)' is not accessible in this context because it is 'Private'.
Do an "add" followed by a "setchildin dex" to move the control to where
you want it. I think this will accomplish what you are trying to do.
Matt
Sorry, I failed to see that you need exclusively for Control.Control s.
Yes, as Matt mentioned you'll need to use SetChildIndex or GetChildIndex
for operating control index change on a ControlCollecti on. The IList
implementation in this object is explicit and throwing
NotSupportedExc eption for Insert (as I can remember...).
ControlCollecti on depends on doing several internal updates for the
owner control when an index is changed... consequently
SetChildIndex/GetChildIndex are used instead.
--
Erick Sgarbi www.blog.csharpbox.com
"Mark Denardo" <ma*********@ru nbox.com> wrote in message
news:N5******** ************@co mcast.com: You'll have to show me an example, because:
tc.controls.ins ert(3, tp) gives me:
- 'Insert' is not a member of 'System.Windows .Forms.Control. ControlCollecti on'.
And tc.Insert(3, tp) gives me:
- 'System.Windows .Forms.TabContr ol.Private Sub Insert(index As Integer, tabPage As System.Windows. Forms.TabPage)' is not accessible in this context because it is 'Private'. "Erick" <no***********@ csharbox.com> wrote in message news:O8******** ******@tk2msftn gp13.phx.gbl... You can use Insert(int index, object item). If we are referring to an ArrayList or CollectionBase it will automatically resize the collection for you.
HTH Erick Sgarbi www.blog.csharpbox.com "Mark Denardo" <ma*********@ru nbox.com> wrote in message news:z9******** ************@co mcast.com:
Hi I have a TabControl object that I need to insert new TabPages into. To append them to the end of the Controls Collection I can do:
tc.controls.add (tp)
(tc - tabcontrol object) (tp - tabpage object)
But how can I insert them into the middle of collection? I see a 'RemoveAt' method that takes an index to remove at a specific location, how come there's not an 'AddAt' or 'Insert' method?
This seems like something that would be quite common for anyone working with TabControls (or any type of Control Collection for that matter). What am I missing here?
Thanks Matt, that solves the Controls Collection part.
tc.Controls.Add (tp)
tc.Controls.Set ChildIndex(tp, index)
I got it to properly place the tabpage in the correct location in the
Controls Collection where I wanted it, but...
But I can't seem to get the TabControl to update it to the proper position.
After I perform the first instruction, the TabControl placed it at the end
of my current list of tabpages, but after the second instruction, the
Controls Collection updated property (because I did a foreach on the
collection and verified it was placed in the correct spot), but the tab I
just added stays at the rear of the tabpages. I guess hoping the TabControl
would do this work for me was being a little too optimistic.
Do you (or anyone working with TabControls) know how I can get the
TabControl to update its TabPages based on it's newly changed Controls
Collection. I searched all of the TabControl and TabPages properties, but
can't seem to find anything that does want I want.
"Matt" <ma********@spr ynet.com> wrote in message
news:11******** **************@ f14g2000cwb.goo glegroups.com.. . Mark Denardo wrote: You'll have to show me an example, because:
tc.controls.ins ert(3, tp) gives me:
- 'Insert' is not a member of 'System.Windows .Forms.Control. ControlCollecti on'.
And tc.Insert(3, tp) gives me:
- 'System.Windows .Forms.TabContr ol.Private Sub Insert(index As Integer, tabPage As System.Windows. Forms.TabPage)' is not accessible in this context because it is 'Private'.
Do an "add" followed by a "setchildin dex" to move the control to where you want it. I think this will accomplish what you are trying to do.
Matt
Mark Denardo wrote: Thanks Matt, that solves the Controls Collection part.
tc.Controls.Add (tp) tc.Controls.Set ChildIndex(tp, index)
I got it to properly place the tabpage in the correct location in the Controls Collection where I wanted it, but...
But I can't seem to get the TabControl to update it to the proper position. After I perform the first instruction, the TabControl placed it at the end of my current list of tabpages, but after the second instruction, the Controls Collection updated property (because I did a foreach on the collection and verified it was placed in the correct spot), but the tab I just added stays at the rear of the tabpages. I guess hoping the TabControl would do this work for me was being a little too optimistic.
Do you (or anyone working with TabControls) know how I can get the TabControl to update its TabPages based on it's newly changed Controls Collection. I searched all of the TabControl and TabPages properties, but can't seem to find anything that does want I want.
Okay, I see what you are doing. No, that isn't going to work. Tab
Controls are more or less set in stone when you display them. You can
*try* to add to them, but you are going to get weird behavior at best.
In order to do this, you need to clear ALL the pages, store them in an
array of tab pages, insert the page you want into that array, then put
the pages back into the control.
I know I saw an example of this one codeproject.com at one point... (as
he runs off and looks). Yep. This should do close to what you want: http://www.codeproject.com/cs/miscct...tabcontrol.asp
matt "Matt" <ma********@spr ynet.com> wrote in message news:11******** **************@ f14g2000cwb.goo glegroups.com.. . Mark Denardo wrote: You'll have to show me an example, because:
tc.controls.ins ert(3, tp) gives me:
- 'Insert' is not a member of 'System.Windows .Forms.Control. ControlCollecti on'.
And tc.Insert(3, tp) gives me:
- 'System.Windows .Forms.TabContr ol.Private Sub Insert(index As Integer, tabPage As System.Windows. Forms.TabPage)' is not accessible in this context because it is 'Private'.
Do an "add" followed by a "setchildin dex" to move the control to where you want it. I think this will accomplish what you are trying to do.
Matt
Yeah that's what I was using as a work around after you showed me the
inserting method, but it seemed hokie and thought there should be a better
way, but I guess clearing and re-adding will be good enough. Ok I
appreciate all of your help.
"Matt" <ma********@spr ynet.com> wrote in message
news:11******** *************@g 14g2000cwa.goog legroups.com... Mark Denardo wrote: Thanks Matt, that solves the Controls Collection part.
tc.Controls.Add (tp) tc.Controls.Set ChildIndex(tp, index)
I got it to properly place the tabpage in the correct location in the Controls Collection where I wanted it, but...
But I can't seem to get the TabControl to update it to the proper position. After I perform the first instruction, the TabControl placed it at the end of my current list of tabpages, but after the second instruction, the Controls Collection updated property (because I did a foreach on the collection and verified it was placed in the correct spot), but the tab I just added stays at the rear of the tabpages. I guess hoping the TabControl would do this work for me was being a little too optimistic.
Do you (or anyone working with TabControls) know how I can get the TabControl to update its TabPages based on it's newly changed Controls Collection. I searched all of the TabControl and TabPages properties, but can't seem to find anything that does want I want.
Okay, I see what you are doing. No, that isn't going to work. Tab Controls are more or less set in stone when you display them. You can *try* to add to them, but you are going to get weird behavior at best.
In order to do this, you need to clear ALL the pages, store them in an array of tab pages, insert the page you want into that array, then put the pages back into the control.
I know I saw an example of this one codeproject.com at one point... (as he runs off and looks). Yep. This should do close to what you want:
http://www.codeproject.com/cs/miscct...tabcontrol.asp
matt "Matt" <ma********@spr ynet.com> wrote in message news:11******** **************@ f14g2000cwb.goo glegroups.com.. . > > Mark Denardo wrote: >> You'll have to show me an example, because: >> >> tc.controls.ins ert(3, tp) gives me: >> >> - 'Insert' is not a member of >> 'System.Windows .Forms.Control. ControlCollecti on'. >> >> And tc.Insert(3, tp) gives me: >> >> - 'System.Windows .Forms.TabContr ol.Private Sub Insert(index As >> Integer, >> tabPage As System.Windows. Forms.TabPage)' is not accessible in this >> context >> because it is 'Private'. > > Do an "add" followed by a "setchildin dex" to move the control to where > you want it. I think this will accomplish what you are trying to do. > > Matt >
This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: jason |
last post by:
How does one loop through the contents of a form complicated by dynamic
construction of checkboxes which are assigned a 'model' and 'listingID' to
the NAME field on the fly in this syntax: Hunter_69. Here is what the form
looks like. I have the difficulty of inserting the multiple items selected
by the user the first time he visits and uses the screen and then using an
UPDATE when he visits later.
Model | Original Price | Reduced Price...
|
by: sam |
last post by:
I have a collection of vb.net objects with LoadXML and SaveXML functions
which use XML serialization to persist the collection.
Is it possible to Update one single object in the collection at a time? Can
I have a SaveXML function on my objects that will persist the object to a
specific node in the collection's xml? Rather than having to overwrite the
entire file when I only want to update one object node.
Sorry if I'm not being clear...
|
by: Sean |
last post by:
HI There,
I am making the transition from asp to asp .net, I am currenty writing an
application that requires a bulk insert from a webform into SQL server,
normally I would just create rows of html textboxes and then use the
Request.Form.Count property to collect each field. What I would like to know
is what is a good way of doing this in asp.net? Do I need to create an array
of textboxes or can I do this fro a datagrid?
|
by: Lelle |
last post by:
Hello !
how can i insert text containg code examples from a textbox into a database
using SQL insert statment.
i have no problem to just add text that dont contains code and script
examples or the illegal chars for the insert command
is it possible to encasulate the text/string so the server doesnt reads the
string as a command?
|
by: Guadala Harry |
last post by:
In an ASCX, I have a Literal control into which I inject a
at runtime.
litInjectedContent.Text = dataClass.GetHTMLSnippetFromDB(someID);
This works great as long as the contains just client-side
HTML, CSS, etc.
What I want to do is somehow insert a *server control* into the , then set the server control's properties at runtime.
| |
by: Guenter |
last post by:
Hi,
I am trying to use the ASP.NET 2.0 FormView as a method to enter data into
my business object.
At the moment, I am trying to do this without a custom DataSourceView
control, but I can't seem to get it working.
I have this code in my Page_Load method (unconditionally, i.e. outside of
ans "if !IsPostBack" blocks):
ctlView.DataSource = currentAccount.GetAccounts();
|
by: npaulus |
last post by:
Hi,
DataSets are usually resource heavy. Instead of having to pass them
from my middle tier to my presentation layer I was wondering if anyone
has developed a custom collection object that is less resource heavy
and can be passed lightweight to the presentation layer.
Thanks,
NJ
|
by: AG |
last post by:
ASP.NET 2.0 aspx page with a FormView bound to an ObjectDataSource to view,
add and edit records.
Can anyone point me to a sample of how to retain the user entered control
values when an insert fails?
In other words, when inserting a new record, user enters data in the
controls, but the insert fails.
When the page posts back all the controls are empty or at their default
values.
I would like to retain the user enter values so they can...
|
by: =?Utf-8?B?bXBhaW5l?= |
last post by:
Hello,
I am completely lost as to why I can't update a DropDownList inside a
DetailsView after I perform an insert into an object datasource. I tried to
simply it down to the core demostration:
default.aspx:
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it.
First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed.
This is as boiled down as I can make it.
Here is my compilation command:
g++-12 -std=c++20 -Wnarrowing bit_field.cpp
Here is the code in...
| |
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth.
The Art of Business Website Design
Your website is...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules.
He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms.
Adolph will...
|
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols.
I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
|
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
| |
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...
| |