|
I am trying to disable a tab page. In this example, I have a tab control with 3 tab pages. What I want to do is if I select say Tab Page 2, then this is disabled and will not let me view the contents.
Here is my code
Private Sub TabControl1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles TabControl1.Click
If TabControl1.SelectedIndex = 1 Then
TabPage2.Enabled = False
End If
End Sub
I have also tried TabPage2.visible = false
Nothing seems to happen when I try the above. What am I doing wrong?
|
|
|
|
|
The TabPage cannot be Disabled. You actually have to remove it from the TabControl's TabPages collection and add it back when you need to show it.
In practice, this is not a good UI design. Tab's put back into the collection will appear at the end of the tab control, effectively rearranging the tabs. There is no way to sort them without removing ALL the TabPage controls and re-adding them in the order that you want them to appear.
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
Dave Kreskowiak wrote: There is no way to sort them without removing ALL the TabPage controls and re-adding them in the order that you want them to appear.
I also used to have a problem with the above problem like the person that post the previous thread. If we could not hide or disable, how about the visitble property? What is the meaning of visible property for each tab page if it still could not hide the page that we want to hide?
On the other hand, if we remove the any page, how about the control on that tab page? Do we need to add it again or not?
|
|
|
|
|
TabPage inherits from Control. Control is what is supplying the Enabled and Visible properties. But, in TabPage, they're not wired up to do anything, so they don't work.
When you remove the TabPage from the TabPages collection, you're just removing an object from a collection. If you don't save that object in another variable or collection somewhere first, it's reference count will drop to 0 and it, and all the controls on it, will be destroyed.
If you save the TabPage somewhere else, then nothing will happen to the controls on that page. They'll still be alive and well, so long as their parent TabPage object is still alive. All you have to do is re-add the TabPage back to the TabPages collection of any TabControl object.
You could even move an entire TabPage, controls and all, from one TabControl to another.
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
Dave Kreskowiak wrote: If you don't save that object in another variable or collection somewhere first, it's reference count will drop to 0 and it, and all the controls on it, will be destroyed.
How to save a TabPage collection?
Dave Kreskowiak wrote: You could even move an entire TabPage, controls and all, from one TabControl to another.
How to move an entire TabPage and its control from one TabControl to another?
|
|
|
|
|
Dim savedTabPage As TabPage = TabControl.TabPages(3)
NewTabControl.TabPages.Add(savedTabPage)
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
Thank you very much for your sample code.
|
|
|
|
|
I done the following and it seems to work.
TabControl1.TabPages.Remove(TabControl1.TabPages(2))
The reason I want to hide/disable a tab page is that, depending on your authority depends if you see the contents of that tab page. Since I cannot hide or disable the tab page, this seems the best way.
|
|
|
|
|
I get an error when I try the following....
TabControl1.TabPages.Remove(TabControl1.TabPages(4))
TabControl1.TabPages.Remove(TabControl1.TabPages(3))
TabControl1.TabPages.Remove(TabControl1.TabPages(2))
TabControl1.TabPages.Remove(TabControl1.TabPages(1))
TabControl1.TabPages.Remove(TabControl1.TabPages(0))
TabControl1.TabPages.Add(TabControl1.TabPages(0)) <==== Error here
TabControl1.TabPages.Add(TabControl1.TabPages(1))
TabControl1.TabPages.Add(TabControl1.TabPages(3))
TabControl1.TabPages.Add(TabControl1.TabPages(4))
What is it I am doing wrong.
|
|
|
|
|
Because you have removed the tab pages from the TabControl1.TabPages collection, they are no longer in that collection. You can't ask for a tab page in a collection from which you just removed it. You have to store the tab pages you removed somewhere else, like an arraylist (or in .net 2.0 a List(Of TabPage)).
private removedPages As New List(Of TabPage)
removedPages.Add(TabControl1.TabPages(4))
removedPages.Add(TabControl1.TabPages(3))
removedPages.Add(TabControl1.TabPages(2))
removedPages.Add(TabControl1.TabPages(1))
removedPages.Add(TabControl1.TabPages(0))
TabControl1.TabPages.Remove(TabControl1.TabPages(4))
TabControl1.TabPages.Remove(TabControl1.TabPages(3))
TabControl1.TabPages.Remove(TabControl1.TabPages(2))
TabControl1.TabPages.Remove(TabControl1.TabPages(1))
TabControl1.TabPages.Remove(TabControl1.TabPages(0))
TabControl1.TabPages.Add(removedPages(0)) <==== Error here
TabControl1.TabPages.Add(removedPages(1))
TabControl1.TabPages.Add(removedPages(3))
TabControl1.TabPages.Add(removedPages(4))
Hope this helps!
"..Commit yourself to quality from day one..it's better to do nothing at all than to do something badly.."
-- Mark McCormick || Fold With Us! || Pensieve || VG.Net ||
|
|
|
|
|
You beat me to it! Thanks Marc!
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
How do i make a label transparent? Do i have to create a new class of label with new properties?
rzvme
|
|
|
|
|
All you have to do is set it's BackColor property to Color.Transparent .
myLabel.BackColor = Color.Transparent
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
-- modified at 10:16 Friday 27th January, 2006
|
|
|
|
|
Label.backcolor = color.transparent
|
|
|
|
|
|
hi
i want to know that how to handle the null values in the database. i had the text field that save the time of incident. in some cases the user does not input the time. i want to check that if time is null means user had given no input. how to make the check of that.
i had used recordset such as
if isnull(rsdata.field("time"))=true then
msgbox"novalue in the database"
else
msgbox"value in the databse is present.
but that does not work it gives error that specified field contain no data or item not listed in the database.
Tell me how to make the check that field is null in database.
ddd
|
|
|
|
|
That is exactly the way that you do it.
Well, the If statement uses a boolean expression, so if you have a boolean value, you don't need to compare it to anything:
If IsNull(rsdata.Field("time")) Then
Are you sure that the field is named "time"? Are you sure that you include that field when you fetch the data to the recordset?
---
b { font-weight: normal; }
|
|
|
|
|
I don't remember why I did it this way, I think there was a problem with IsNull not working wit DBNull in one of the projects I did.
Here was the workaround I came up with:
For Each Item As DataRow In Questions.Rows
If Item("question_fields").GetType.Name <> "DBNull" Then
...
End if
Next
Matthew Hazlett
Sometimes I miss the simpler DOS days of Borland Turbo Pascal (but not very often).
|
|
|
|
|
|
Assuming you can change the select statement, check for null values within the query. If necessary, change the value to a non-time value (such as the literal word 'NULL') and then have your code check for that constant.
|
|
|
|
|
Hello,
I am a VB6 programmer who has just downloaded VB.Net Express 2005.
I was wondering if there were any comboboxes with a multicolumn dropdown list built into VB.Net, or do we have to build our own custom control. If a custom control is necessary, can anyone recommend a book on building controls, or indeed a freeware control available on the internet.
I have programmed Access a lot and am used to the useful multicolumn comboboxes available there, and want to bring all that functionality to my VB.Net applications.
Many thanks,
Trimtrom
|
|
|
|
|
There isn't any built in support for it in the .NET Framework. But, there are lots of examples on how to build one. All you need to do is search the articles for Multicolumn Combobox[^].
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
|
An unhandeled execption has occured in your application.If you click continue the application will ignore this error and attempt to cont. if u click quit the appln will shut down immediately.
Object reference not set to an instance of an object....
and one more error...
SQL server access denied.
bhavna
|
|
|
|
|
Bhavna Varshney wrote: An unhandeled execption has occured in your application.If you click continue the application will ignore this error and attempt to cont. if u click quit the appln will shut down immediately.
Object reference not set to an instance of an object....
and one more error...
SQL server access denied.
And your question is...?
...Steve
"Give a man a fish and you've fed him for a day. Teach him how to fish and you've fed him for life." (Translation: I'll show you the way, but not write the code for you.) I read that somewhere once
|
|
|
|