TabPages Disabling
-
Hi, I need to disable a tabpage in a tabcontrol. I 've tried to set the property "Enabled" to FALSE, but it doesn't shadow the text. So I tried to set the forecolor property of the tabpage, but it doesn't work. Finally I tried to draw each item by code as Microsoft suggests(through the drawitem event), but the result is really ugly (it losts the visual effects and the text doesn't fit in the bounds). I cannot remove and re-add the pages for 2 reasons: 1) Each page could be enabled or disabled depending on several values in the form, so it is difficult to re-add the page in the right place 2) I LIKE the behaviour of old VB6 tabcontrol. Can anyone help me ??? Thanx a lot.
Peace!
-
Hi, I need to disable a tabpage in a tabcontrol. I 've tried to set the property "Enabled" to FALSE, but it doesn't shadow the text. So I tried to set the forecolor property of the tabpage, but it doesn't work. Finally I tried to draw each item by code as Microsoft suggests(through the drawitem event), but the result is really ugly (it losts the visual effects and the text doesn't fit in the bounds). I cannot remove and re-add the pages for 2 reasons: 1) Each page could be enabled or disabled depending on several values in the form, so it is difficult to re-add the page in the right place 2) I LIKE the behaviour of old VB6 tabcontrol. Can anyone help me ??? Thanx a lot.
Peace!
You two choices. One is to draw the tabs yourself, fixing your drawing code. I wish I had some examples to give you but I just about never use the TabControl, except in an Options dialog. The other is to find a 3rd party TabControl that supports the visual effects you want. I don't know of any off the top of my head, well, because I just about never use the TabControl. ;)
A guide to posting questions on CodeProject[^]
Dave Kreskowiak Microsoft MVP Visual Developer - Visual Basic
2006, 2007 -
Hi, I need to disable a tabpage in a tabcontrol. I 've tried to set the property "Enabled" to FALSE, but it doesn't shadow the text. So I tried to set the forecolor property of the tabpage, but it doesn't work. Finally I tried to draw each item by code as Microsoft suggests(through the drawitem event), but the result is really ugly (it losts the visual effects and the text doesn't fit in the bounds). I cannot remove and re-add the pages for 2 reasons: 1) Each page could be enabled or disabled depending on several values in the form, so it is difficult to re-add the page in the right place 2) I LIKE the behaviour of old VB6 tabcontrol. Can anyone help me ??? Thanx a lot.
Peace!
Hello :) Try this that at the event of paint event of your tab page set its focus to some other or next object. Example: Private Sub tabpage1_Paint(ByVal sender As Object, ByVal e As System.Windows.Forms.PaintEventArgs) Handles tabpage1.Paint tabpage2.Selected = True End Sub Regards Ali Raza
-
Hello :) Try this that at the event of paint event of your tab page set its focus to some other or next object. Example: Private Sub tabpage1_Paint(ByVal sender As Object, ByVal e As System.Windows.Forms.PaintEventArgs) Handles tabpage1.Paint tabpage2.Selected = True End Sub Regards Ali Raza
Nice idea, the controls inside the page don't respond anymore. This can be obtained (with grayed controls) also by setting the property enabled of the tabpage... But doesn't resolve the problem of graying the tabpage title. Thanks, anyway. For other friends: the command is TabPage2.Select (is a method, not a property). Regards, Advansis
Peace!