Disable tabcontrol from clicking

Please support our VB.NET advertiser: Intel Parallel Studio Home
Thread Solved

Join Date: Jan 2009
Posts: 21
Reputation: rak4u is an unknown quantity at this point 
Solved Threads: 0
rak4u rak4u is offline Offline
Newbie Poster

Disable tabcontrol from clicking

 
0
  #1
Jan 15th, 2009
Hi all i am a newbie in development
I have a window application in vb.net in VS 2003 there is a tabcontrol which has three tab pages.
i want that user was not able to change tabpages by clicking tabcontrol rahter than it is done by clicking button on tabpages how it is possible
please help me
thanks in advance
Report post as abusive
Reply With Quote Quick reply to this message  
Join Date: Aug 2006
Posts: 2,065
Reputation: Ramy Mahrous is just really nice Ramy Mahrous is just really nice Ramy Mahrous is just really nice Ramy Mahrous is just really nice 
Solved Threads: 256
Featured Poster
Ramy Mahrous's Avatar
Ramy Mahrous Ramy Mahrous is offline Offline
Postaholic

Re: Disable tabcontrol from clicking

 
0
  #2
Jan 15th, 2009
Hold current TabPageIndex in integral variable, and once the click done on any TabPage set the TabControl SelectedIndex = the integral value tabControl1.SelectedIndex = integral variable;
BI Developer | LINKdotNET
B.Sc Computer Science, Helwan University
Technical blog | http://ramymahrous.wordpress.com
LinkedIn | http://www.linkedin.com/in/ramymahrous
Reply With Quote Quick reply to this message  
Join Date: Aug 2006
Posts: 2,065
Reputation: Ramy Mahrous is just really nice Ramy Mahrous is just really nice Ramy Mahrous is just really nice Ramy Mahrous is just really nice 
Solved Threads: 256
Featured Poster
Ramy Mahrous's Avatar
Ramy Mahrous Ramy Mahrous is offline Offline
Postaholic

Re: Disable tabcontrol from clicking

 
0
  #3
Jan 15th, 2009
You can also do it in the event handler of the TabControl.SelectedIndexChanged
BI Developer | LINKdotNET
B.Sc Computer Science, Helwan University
Technical blog | http://ramymahrous.wordpress.com
LinkedIn | http://www.linkedin.com/in/ramymahrous
Reply With Quote Quick reply to this message  
Join Date: Jan 2009
Posts: 21
Reputation: rak4u is an unknown quantity at this point 
Solved Threads: 0
rak4u rak4u is offline Offline
Newbie Poster

Re: Disable tabcontrol from clicking

 
0
  #4
Jan 16th, 2009
I am able to show specific tab page on button click. but i did not want user to change tabpage by clicking on tabcontrol but by clicking button only


I tried one solution but it is not full proof It may cause error in later part

on load event of form i give

dim tab as integer =1

then when user click on tabcontrol then on validating event of tabpage i put the code that

if tab=1 then
e.cancel=true
else
end if

so when user click on tabcontrol than tab=1 so the tabpage is not changed

on button click event i used this code

tab=2
tabcontol1.selectedtabindex=1

so now tab is not 1 so it will not trap on if else coding of validating event & user will able to change tab page by clicking on button not on clicking tabcontrol because in end of elseif event i again value tab=1

  1.  
  2.  
  3. Private Sub Browse_Validating(ByVal sender As Object, ByVal e As System.ComponentModel.CancelEventArgs) Handles Browse.Validating
  4.  
  5. If tab = 1 Then (tab is a variable)
  6.  
  7. e.Cancel = True
  8.  
  9. Else
  10.  
  11. End If
  12.  
  13. tab = 1
  14.  
  15. End Sub
and on button click event

tab=2

tabcontrol1.selectedtab = browse
Last edited by Ancient Dragon; Jan 16th, 2009 at 6:27 pm. Reason: add code tags
Reply With Quote Quick reply to this message  
Join Date: Jan 2009
Posts: 21
Reputation: rak4u is an unknown quantity at this point 
Solved Threads: 0
rak4u rak4u is offline Offline
Newbie Poster

Re: Disable tabcontrol from clicking

 
0
  #5
Jan 16th, 2009
I only entered in the programming job since last 2 month. I am working in Publighing house. they have no IT department Or IT staff. They want to develop their data entry program in vb.net & SQL server.
AS i mention i am a newbie no experience of any type. So i develop most of their model window application by taking help og internet & books but here i got in problem

My application is window application for dataentry. It has three tabpages First tab page is filter which is use to specify fitering condition to filter data from database & display that in datagrid present in second tab page browse. oN BROWSE TABPAGE i can present that data in excel format & also in crystal report.
then there is third tabpage ADDEDIT. On which ican edit the record or add new record. Tell me how u think about my approach to develop that application. Any suggesion help or improvement in any aspect will welcom & must be appriciated

Now coming on current problem
As there is no selecting event in VS 2003 So what u think about using IMessageFilter.PreFilterMessage
function & trap the click event od tabcontrol. I dont know how to use that function.

please tell me is that function is useful in this scenerio & if yes than please tell me any link to use IMessageFilter.PreFilterMessage function to capture click event of tabcontrol

again thanks all for ur support & help

bye
Reply With Quote Quick reply to this message  
Join Date: Aug 2008
Posts: 710
Reputation: Teme64 will become famous soon enough Teme64 will become famous soon enough 
Solved Threads: 114
Teme64's Avatar
Teme64 Teme64 is offline Offline
Master Poster

Re: Disable tabcontrol from clicking

 
0
  #6
Jan 16th, 2009
Tab-control is supposed to work by user selecting any tab he or she wants to and in any order he/she wants to select it. This is not to say that your approach is "wrong".

But like you noticed you ended up thinking about using IMessageFilter.PreFilterMessage. If your not familiar with programming that will lead you in a deep s**t.

Another way to do it, would be to use three overlapping GroupBox controls in a form. One for each stage your prog currently is in and setting Visible-property according to which "page" you want to show. Of course, the "Next Page"-button is in the form outside of any of the groupboxes.

Inside the first groupbox you set all the controls needed for the filter and so on. After you've built all three groupboxes, drag (or copy/paste) them over each other. Use a global variable to hold the stage of your prog, like Page = 1 and set first gb visible and hide other boxes. After the user presses "next"-button, increase Page variable and set visible properties for the groupboxes so that only the second gb is visible.

I don't have VB2003 but it should work just fine. I've done similar thing with VB6 so I don't see any reason why it wouldn't work in VB2003.
Reply With Quote Quick reply to this message  
Join Date: Jan 2009
Posts: 21
Reputation: rak4u is an unknown quantity at this point 
Solved Threads: 0
rak4u rak4u is offline Offline
Newbie Poster

Re: Disable tabcontrol from clicking

 
0
  #7
Jan 16th, 2009
thanks for reply i am understanding ur suggetion. But my project is completed in all respect & this is the shortcoming tell by my boss not allow user to click tabcontrol(its not my idea) I know what is the use of tabcontrol if user is not allowed to click & select tabpages of his choice so i have to make change on current project itself
please tell any suggetion idea or method

by the way thanks all of u for ur effort
Reply With Quote Quick reply to this message  
Join Date: Jan 2009
Posts: 1
Reputation: tomshin is an unknown quantity at this point 
Solved Threads: 1
tomshin tomshin is offline Offline
Newbie Poster

Re: Disable tabcontrol from clicking

 
0
  #8
Jan 16th, 2009
By the buttons have properties Enable = TRUE or
Reply With Quote Quick reply to this message  
Join Date: Aug 2008
Posts: 710
Reputation: Teme64 will become famous soon enough Teme64 will become famous soon enough 
Solved Threads: 114
Teme64's Avatar
Teme64 Teme64 is offline Offline
Master Poster

Re: Disable tabcontrol from clicking

 
0
  #9
Jan 16th, 2009
Here's a code that should be compatible with VB2003/.NET 1.1
  1. Private TabIX As Integer
  2.  
  3. Private Sub Form1_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
  4. '
  5. TabIX = 0
  6.  
  7. End Sub
  8.  
  9. Private Sub TabControl1_SelectedIndexChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles TabControl1.SelectedIndexChanged
  10. '
  11. TabControl1.SelectedTab = TabControl1.TabPages.Item(TabIX)
  12. End Sub
  13.  
  14. Private Sub Button1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button1.Click
  15. '
  16. If TabIX < TabControl1.TabPages.Count - 1 Then
  17. TabIX = TabIX + 1
  18. TabControl1.SelectedTab = TabControl1.TabPages.Item(TabIX)
  19. End If
  20.  
  21. End Sub
and put the "Next Page"-button in the form outside of the tab control. If your "Next Page"-buttons resides in tab pages i.e. you have more than one "Next Page"-button then you can use the same event handler for them: Handles Button1.Click, Button2.Click, Button3.Click
Reply With Quote Quick reply to this message  
Join Date: Jan 2009
Posts: 21
Reputation: rak4u is an unknown quantity at this point 
Solved Threads: 0
rak4u rak4u is offline Offline
Newbie Poster

Re: Disable tabcontrol from clicking

 
0
  #10
Jan 17th, 2009
I have solved the problem & if any body need that so iam posting code below

I declare a global variable tab & assign its value tab=1 on form's load event & on tabcontrol selectedindexchanged event use

Private Sub TabControl1_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles TabControl1.SelectedIndexChanged

TabControl1.TabPages(TabControl1.SelectedIndex).Focus()

TabControl1.TabPages(TabControl1.SelectedIndex).CausesValidation = True

End Sub

on validating event of tabpages

Private Sub Filter_Validating(ByVal sender As Object, ByVal e As System.ComponentModel.CancelEventArgs) Handles Filter.Validating

If tab = 1 Then
e.Cancel = True
Else
End If

End Sub

enter event of tabpages

Private Sub Filter_Enter(ByVal sender As Object, ByVal e As System.EventArgs) Handles Filter.Enter
tab = 1
End Sub

because validating event fires on when tabpage is selected
so use textbox1.select()
now on closing event of from i used

e.cancel = false

& to able to change tabpages on button click I used on button click event

tab=2

because now it escapes from if else loop of validating event of tabpage

In end thanks all of u for ur help

Bye
Last edited by rak4u; Jan 17th, 2009 at 12:45 am.
Reply With Quote Quick reply to this message  
Reply

This thread has been marked solved.
Perhaps start a new thread instead?
Message:



Other Threads in the VB.NET Forum
Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC