473,403 Members | 2,354 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,403 software developers and data experts.

cant close a tabpage from another winform

Hi guyz,


need help....!!! i have tabcontrol1 in mainform1 which dynamically adds a new tabpage based on the no of times a button is clicked on the main menubar.

eg:

if tabpage1 is created dynamically, tabpage1 will be showing form2 inside it. Therz a button2 on form2 , on its clicking it should close tabpage1 along with form2 I tried this code on Form2,

Form2
---------

Button2_clickevent
{
mainform1 obj = new mainform1();
obj.tabcontrol1.tabpages.remove(tabpage1);
}

it doesnt show any response.....cant close.......

plz help guyz.................urgent :(



Thanks in advance
Sep 30 '07 #1
7 1412
kenobewan
4,871 Expert 4TB
Welcome to TSDN. One problem you have appear to have is with referencing. Have a think about it not working and showing no errors. Is this the case?
Sep 30 '07 #2
Welcome to TSDN. One problem you have appear to have is with referencing. Have a think about it not working and showing no errors. Is this the case?


thats right.....doesnt show any errors...........but on clickin.......nothin happens
Sep 30 '07 #3
Welcome to TSDN. One problem you have appear to have is with referencing. Have a think about it not working and showing no errors. Is this the case?

tats right.......m in a fix........wat should i do?
Oct 1 '07 #4
Plater
7,872 Expert 4TB
Well for starters:
Expand|Select|Wrap|Line Numbers
  1. Button2_clickevent
  2. mainform1 obj = new mainform1();
  3. obj.tabcontrol1.tabpages.remove(tabpage1);
  4. }
  5.  
You are creating a NEW instance of the mainform1 class, not editing an existing one. So you will not see anything happening and there will probably not be any errors. (Either that function does not error when that tab doesn't exist, or it already does)

The original reply suggesting you think on why your references are wrong is correct.
Oct 1 '07 #5
Well for starters:
Expand|Select|Wrap|Line Numbers
  1. Button2_clickevent
  2. mainform1 obj = new mainform1();
  3. obj.tabcontrol1.tabpages.remove(tabpage1);
  4. }
  5.  
You are creating a NEW instance of the mainform1 class, not editing an existing one. So you will not see anything happening and there will probably not be any errors. (Either that function does not error when that tab doesn't exist, or it already does)

The original reply suggesting you think on why your references are wrong is correct.

HI Plater,

I tried these codes u suggested but aint workin.........or any public function i defined inside mainform1 , i cant access it from button2 click event. wat is te reason???
Oct 3 '07 #6
Shashi Sadasivan
1,435 Expert 1GB
HI Plater,

I tried these codes u suggested but aint workin.........or any public function i defined inside mainform1 , i cant access it from button2 click event. wat is te reason???
So...are you still using
Expand|Select|Wrap|Line Numbers
  1. mainform1 obj = new mainform1();
cheers
Oct 3 '07 #7
So...are you still using
Expand|Select|Wrap|Line Numbers
  1. mainform1 obj = new mainform1();
cheers

Thanks guyz for the support.got the answer. declared a custom event handler in my form1 and initiated it from mainform1. Bingo...there u have it..........Thankz guyz



:)
Oct 5 '07 #8

Sign in to post your reply or Sign up for a free account.

Similar topics

3
by: Benne | last post by:
Hi, Does anybody know if it's possible to have the small "x" on the tabpages in a tabcontrol ? I need a nice way to close them, without a big, ugly buttom on the tabpage itself. It would be cool...
0
by: CMEDIA_SOUND | last post by:
I have a peculiar problem, I have a tabpage with a label control on it. When i set a background image to the tabpage and drag the label around it has paint issues in that it is slow, granted the...
2
by: JG | last post by:
Hi, I have a windows form with a TabControl on it. It has 3 tabpages on it. I have also coded a button that is supposed to 'add' a new tabpage. The code in that clicked event looks like this:...
2
by: Sean | last post by:
Hi all, I have few OwnerDraw TabPage icons. The problem that I am having now is that when another window go over the icons, they don't redraw properly (meaning you either cannot see the icon at...
3
by: Cynthia | last post by:
I knew that "Hide" doesn't work with Tabpage if I want to hide it. I should use Remove/Add. But I have some other controls in the tabpage which I don't want to use code to dynamiclly create them....
6
by: Tee | last post by:
Hi, I have a tabcontrol that has a tabpage, I want to add another tabpage on runtime, but I want the tabpage to be added to the 1st tab, anyone know how to do it? Thanks, Tee
8
by: Andre Nogueira | last post by:
Hi there. I would like to know it is possible in VB.Net 2003 to see that a user has clicked a tab page. My goal is to close the tab page if the user clicks a tabpage "separator" (not sure how to...
2
by: moondaddy | last post by:
I had to repost this because I had to update and change my msdn alias. I will re-ask the question and clarify a few things that were not clear before. This code is all executed on my dev...
0
by: klaas | last post by:
Hi, i've a problem to save the value of a radiobuttum in a groupbox on a winform with multiple tabpages. when i place the groubox out of the tabpage i come into my procedure of...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
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...
0
Oralloy
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,...
0
tracyyun
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...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
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...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.