473,398 Members | 2,404 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,398 software developers and data experts.

Stop Tab Page being selected in TabControl

Hi all

I want to be able to prevent a particular tab from being selected at
run-time, how would I go about doing that?

At the moment, I have created a custom control and inherited the TabControl.
I then override the WndProc method and trap the WM_NCHITTEST message (I
don't know if this is the correct message to watch out for).

I need to check to see if the tab that they are clicking on is Enabled or
not (Eg. TabPage1.Enabled = False) and if the Enabled is False then I want
to ignore the message so the tab doesn't change, otherwise forward the
message on as normal.

Am I going about it the right way or is there a better way to do this??

Kind Regards,
Steve.
Jul 21 '05 #1
2 2533
Hi all

Ok. I have the code I need to disable the tab page, but this code is run in
the OnDrawItem event, and this event doesn't get fired until the tab page
either gets focus or loses focus, so if I set the Enabled property to False
and I'm not already on the tab, it will never appear to be greyed out.

So my question is, how can I force the OnDrawItem event? If I can do some
sort of refresh for the tab page I have just set the Enabled property for
then the event will be run and the tab page will be disabled.

Kind Regards,
Steve.

"Steve Amey" <stevea@centurion-ms_RemoveThis_.co.uk> wrote in message
news:%2****************@TK2MSFTNGP09.phx.gbl...
Hi all

I want to be able to prevent a particular tab from being selected at
run-time, how would I go about doing that?

At the moment, I have created a custom control and inherited the TabControl. I then override the WndProc method and trap the WM_NCHITTEST message (I
don't know if this is the correct message to watch out for).

I need to check to see if the tab that they are clicking on is Enabled or
not (Eg. TabPage1.Enabled = False) and if the Enabled is False then I want
to ignore the message so the tab doesn't change, otherwise forward the
message on as normal.

Am I going about it the right way or is there a better way to do this??

Kind Regards,
Steve.

Jul 21 '05 #2
You'll find a few tips on TabControl manipulation on my site.
http://dotnetrix.co.uk/tabcontrols.html

--
Mick Doherty
http://dotnetrix.co.uk/nothing.html
"Steve Amey" <stevea@centurion-ms_RemoveThis_.co.uk> wrote in message
news:%2****************@TK2MSFTNGP09.phx.gbl...
Hi all

I want to be able to prevent a particular tab from being selected at
run-time, how would I go about doing that?

At the moment, I have created a custom control and inherited the
TabControl.
I then override the WndProc method and trap the WM_NCHITTEST message (I
don't know if this is the correct message to watch out for).

I need to check to see if the tab that they are clicking on is Enabled or
not (Eg. TabPage1.Enabled = False) and if the Enabled is False then I want
to ignore the message so the tab doesn't change, otherwise forward the
message on as normal.

Am I going about it the right way or is there a better way to do this??

Kind Regards,
Steve.

---
Outgoing mail is certified Virus Free.
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.742 / Virus Database: 495 - Release Date: 19/08/2004
Jul 21 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: Pete | last post by:
I have some funky form/event behavior. Access 97. Split frontend/backend, using Access security. I have the same behavior (or lack of behavior) for the pag_Click() event of two separate pages...
1
by: Rachel Suddeth | last post by:
I have an form where the whole display is a tab control (well, that plus a status bar.) I want to set the focus to the first TextBox on the first TabPage when it loads. I tried to put that into...
2
by: Scott Gunn | last post by:
In my app I want to have a run-time generated tab showing various controls - for instance a form for a user to fill in. I have a tab page in a hidden tabcontrol and all I want to do is clone it...
2
by: Steve Amey | last post by:
Hi all I want to be able to prevent a particular tab from being selected at run-time, how would I go about doing that? At the moment, I have created a custom control and inherited the...
1
by: jaffar | last post by:
hi, I am using Tab control, i added the tab pages , i want to change the tab pages color when ever i select the tab page, i have tabpage1,tabpage2,tabpage3 i mean when ever i select the tab...
4
by: Bob Alston | last post by:
Anyone have any code handy for handling logical paging when using tabs to handle a multiple page form? What I have read, you can make each tab one of the pages, hide all but the active tab and...
0
by: Redback | last post by:
Im using VS 2005. I have a form with a tab control. I have text boxes which are bound to a binding source, which is bound to a dataset. I have a button on the form that allows the user to add...
2
by: Richard Carpenter | last post by:
I have a four-page tabcontrol with a gridview on each page. I have the primary key column of each gridview set to hidden (visible = false), but it still shows up on all but the first page. Anyone...
8
by: Bhujanga | last post by:
I have a form with a tab control on it that has about 5 tabs.When one of the tabs is selected, I want to set the "Visible" property from "No" to "Yes" on a subform that resides on the main form, but...
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: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
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
jinu1996
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...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
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.