473,763 Members | 9,275 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

tabstrip (disable(grey out) a specific tab)

Hi,

I have a tabstrip and I have some tabs in it. On the first page, all
the tabs are enabled, I need to disbale part of the tabs at a specific
point in the application and again enable them. I have a hard time
doing this. This is concerned with a production issue. Could anyone
please suggest me a solution to this.

I appreciate your time and help.

Thanks and Regards,
Sita.

Nov 17 '05 #1
2 3426
hi,

do you mean controls in a tab or the actual tabpage?

if you want to disable the tabpage's content and if you have a button that
is clicked to enable/disable it try this in the button's click event:

//Replace item with the name of the item.
//You can also add more items and add the '.Enabled = false;' after the
item's name
item.Enabled = false;

--
Alvo von Cossel I of Germany
"tottigang" wrote:
Hi,

I have a tabstrip and I have some tabs in it. On the first page, all
the tabs are enabled, I need to disbale part of the tabs at a specific
point in the application and again enable them. I have a hard time
doing this. This is concerned with a production issue. Could anyone
please suggest me a solution to this.

I appreciate your time and help.

Thanks and Regards,
Sita.

Nov 17 '05 #2
Here is a VB.Net class you can add to your project that gives you a real
Enabled property:

Option Strict On

'============== =============== =============== =============== =============== ===========
' Classe : TabControlEx.vb
'
' Auteur : Eric Moreau
' Concept S2i inc.
'
' Description : System.Windows. Forms.TabContro l Extender
'
' Utilisation : 1. Add a regular TabControl to your form
' 2. In the " Windows Form Designer generated code "
section,
' replace System.Windows. Forms.TabContro l by
TabControlEx (2 places)
' 3. In the Form_Load event (or a similar place), add this
line
' YourTabControlN ame.DrawMode =
TabDrawMode.Own erDrawFixed
' 4. If you want to disable a tabpage, add this line
' YourTabControlN ame.DisablePage (YourTabPageNam e)
'
' Historique :
' Auteur Date Intervention
' ----------------- --------------- -------------------------------------------------
' Eric Moreau 2004/02/15 Création
'============== =============== =============== =============== =============== ===========

Public Class TabControlEx
Inherits System.Windows. Forms.TabContro l

Private Const WM_LBUTTONDOWN As Integer = &H201

Protected Overrides Sub WndProc(ByRef m As System.Windows. Forms.Message)
If m.Msg = WM_LBUTTONDOWN Then
Dim pt As New Point(m.LParam. ToInt32)
Dim index As Integer
For index = 0 To Me.TabPages.Cou nt - 1
If GetTabRect(inde x).Contains(pt) Then
If TabPages(index) .Enabled Then
MyBase.WndProc( m)
End If
Exit Sub
End If
Next
End If
MyBase.WndProc( m)
End Sub

Protected Overrides Sub OnKeyDown(ByVal ke As
System.Windows. Forms.KeyEventA rgs)
Dim currentIndex As Integer = Me.SelectedInde x
Dim index As Integer
If ke.KeyCode = Keys.Left AndAlso Not (ke.Alt AndAlso Not
ke.Control) Then
For index = currentIndex - 1 To 0 Step -1
If TabPages(index) .Enabled Then
Me.SelectedInde x = index
Exit For
End If
Next
ke.Handled = True
ElseIf ke.KeyCode = Keys.Right AndAlso Not (ke.Alt AndAlso Not
ke.Control) Then
For index = currentIndex + 1 To TabPages.Count - 1
If TabPages(index) .Enabled Then
Me.SelectedInde x = index
Exit For
End If
Next
ke.Handled = True
End If
MyBase.OnKeyDow n(ke)
End Sub

Public Sub DisablePage(ByR ef pTabPage As TabPage)
With pTabPage
.Enabled = False
'.Text = "(* " & .Text & " *)"
End With
End Sub

Private Sub TabControlEx_Dr awItem(ByVal sender As Object, ByVal e As
System.Windows. Forms.DrawItemE ventArgs) Handles MyBase.DrawItem
Dim intOffsetLeft As Int32
Dim intOffsetTop As Int32
Dim r As RectangleF = RectangleF.op_I mplicit(e.Bound s)
Dim r2 As RectangleF
Dim ItemBrush As New SolidBrush(Me.B ackColor)
Dim b As Brush ' SolidBrush = New
SolidBrush(TabC ontrol1.ForeCol or)
If Me.TabPages(e.I ndex).Enabled Then
b = Brushes.Black
Else
b = Brushes.Gray
End If

Dim sf As New StringFormat
sf.Alignment = StringAlignment .Center
sf.LineAlignmen t = StringAlignment .Center

Dim im As Bitmap
If Me.TabPages(e.I ndex).ImageInde x <> -1 Then
im = CType(Me.ImageL ist.Images(Me.T abPages(e.Index ).ImageIndex),
Bitmap)
End If

If Me.TabPages(e.I ndex).ImageInde x <> -1 Then
r2 = New RectangleF(r.X + (im.Width \ 2), r.Y, r.Width,
r.Height)
Else
r2 = New RectangleF(r.X, r.Y, r.Width, r.Height)
End If

If CBool(e.State And DrawItemState.S elected) Then
e.Graphics.Fill Rectangle(ItemB rush, e.Bounds)
e.Graphics.Draw String(Me.TabPa ges(e.Index).Te xt, e.Font, b, r2,
sf)
'e.Graphics.Dra wString(TabCont rol1.TabPages(e .Index).Text,
e.Font, Brushes.Red, r2, sf)
intOffsetLeft = 5
intOffsetTop = 5 '4
Else
e.Graphics.Draw String(Me.TabPa ges(e.Index).Te xt, e.Font, b, r2,
sf)
'e.Graphics.Dra wString(TabCont rol1.TabPages(e .Index).Text,
e.Font, Brushes.Blue, r2, sf)
intOffsetLeft = 2
intOffsetTop = 2 '4
End If

If Me.TabPages(e.I ndex).ImageInde x <> -1 Then
Me.ImageList.Dr aw(e.Graphics, Convert.ToInt32 (r.Left) +
intOffsetLeft, Convert.ToInt32 (r.Top) + intOffsetTop,
Me.TabPages(e.I ndex).ImageInde x)
End If
End Sub
End Class
--
HTH

Éric Moreau, MCSD, Visual Developer - Visual Basic MVP
(http://aspnet2.com/mvp.ashx?EricMoreau)
Conseiller Principal / Senior Consultant
Concept S2i inc. (www.s2i.com)

"tottigang" <si****@gmail.c om> wrote in message
news:11******** *************@o 13g2000cwo.goog legroups.com...
Hi,

I have a tabstrip and I have some tabs in it. On the first page, all
the tabs are enabled, I need to disbale part of the tabs at a specific
point in the application and again enable them. I have a hard time
doing this. This is concerned with a production issue. Could anyone
please suggest me a solution to this.

I appreciate your time and help.

Thanks and Regards,
Sita.

Nov 17 '05 #3

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

Similar topics

2
1949
by: jerry.ranch | last post by:
I'm starting to learn about the tab control. How would I write an on open event procedure in VBA, that upon opening of the form, a specific tab opens (say tab 1)? Thanks Jerry
0
1252
by: sakieboy | last post by:
I'm working with ASP.Net 1.1. I have a user control that displays a javascript/DHTML calendar (because the normal calendar is clunky-real estate issue). I am using Microsoft.Web.UI.Webcontrols for the Tabstrip. On the first tab I have a date user control, it works.... when I select next to proceed to the next tab, I write the information to the DB(SQL) because I need the ID. I have a date user control on the second tab, when I select...
3
1752
by: mcena | last post by:
Hi pals. I am wring this program and I am using the tabstrip control with about 6 tabs. I am not able to pass program control to a specific tab. In my program, the following code enables me to write instructions for each tab. Private Sub SSTab1_Click(PreviousTab As Integer) If SSTab1.Caption = "Suppliers" Then openSupplierRS ElseIf SSTab1.Caption = "Agents" Then openAgentRS End If '----------------------(up to 6...
3
2019
ADezii
by: ADezii | last post by:
One frequently asked question at TheScripts is how to set focus/make active a specific Tab on a Tab Control other than clicking on it. Before I provide the answer, I feel as though a little summary information would be most helpful. __1. An individual Tab on a Tab Control is actually a Page Object. For this discussion, we will use the terms Tab/Page interchangeably, however. __2. Each Page Object is a member of the Pages Collection which...
4
44117
ADezii
by: ADezii | last post by:
One frequently asked question at TheScripts is how to set focus/make active a specific Tab on a Tab Control other than clicking on it. Before I provide the answer, I feel as though a little summary information would be most helpful. __1. An individual Tab on a Tab Control is actually a Page Object. For this discussion, we will use the terms Tab/Page interchangeably, however. __2. Each Page Object is a member of the Pages Collection which...
4
1854
by: hariadusumalli | last post by:
Hi, I added a tab control to my form. I need to add the tab pages to the control at run-time. But this is little different from the normal way. I need to display one specific tab to the right most, while the other tabs can be from left to right. Do I need to inherit the control and specify the location for the specific tab? Please suggest how to do this?? Thanks,
2
1846
by: dmorand | last post by:
I've got a field in my database, and I want to retrieve all characters to the left of the first number value encountered. I'm not quite sure how to accomplish this Here is an example of a field I'm working with: PREDNISONE 10 MG = 2 TAB (10 MG = 2 TAB TAB) I want to retrieve the value: PREDNISONE Any ideas?
1
11240
by: Coolboy55 | last post by:
How do I open a form to a specific tab? Thanks, CB55
2
3129
by: ncsthbell | last post by:
Hello, I have an application that opens on a 'Main Form' and that form has 10 different tab selections. I need to be able to position a certain user to one of the tabs as if they had clicked on the tab. Can someone help to direct me on this. I inherted this application and do not have experience working with tabs. Thanks!
0
9564
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9387
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,...
0
10148
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, 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...
0
10002
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 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...
0
9823
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 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...
0
8822
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7368
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 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...
0
6643
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
1
3917
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 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.