473,382 Members | 1,658 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,382 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 2532
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...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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...

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.