Hi,

I have an administrator form that contain 4 tabs. Depending of what privileges the user have the user have access to some tab.

Here is the code that I use :

VB Code:
  1. Dim strPrivileges As String = AvoirDroitUsager()
  2.         Me.tabAdmin.Controls().Remove(Me.TabPage1)
  3.         Me.tabAdmin.Controls().Remove(Me.TabPage2)
  4.         Me.tabAdmin.Controls().Remove(Me.TabPage3)
  5.         Me.tabAdmin.Controls().Remove(Me.TabPage4)
  6.  
  7.         If InStr(strPrivileges, "P") > 0 Then
  8.             Me.tabAdmin.Controls().Add(Me.TabPage1)
  9.             Me.tabAdmin.Controls().Add(Me.TabPage2)
  10.             Me.tabAdmin.Controls().Add(Me.TabPage3)
  11.             Me.tabAdmin.Controls().Add(Me.TabPage4)
  12.         Else
  13.             If InStr(strPrivileges, "A") > 0 Then
  14.                 Me.tabAdmin.Controls().Add(Me.TabPage4)
  15.             End If
  16.             If InStr(strPrivileges, "C") > 0 Then
  17.                 Me.tabAdmin.Controls().Add(Me.TabPage2)
  18.             End If
  19.  
  20.             If InStr(strPrivileges, "M") > 0 Then
  21.                 Me.tabAdmin.Controls().Add(Me.TabPage3)
  22.             End If
  23.         End If

The problem is that I can't close the form since I have implemented that piece of code... why?