فرمی که این TextBox توی اون قرارداره یک خصوصیت RegistryHive داره که باید قبل از Load در پنجره Owner مقدار دهی بشه:
Private RegistryHiveValue As RegistryHive
Public Property RegistryHive() As RegistryHive
Get
Return RegistryHiveValue
End Get
Set(ByVal value As RegistryHive)
RegistryHiveValue = value
End Set
End Property
و برای کلید های اولیه از RegistryHive و مقدار دهی به متغیر Key که یک RegistryKey هست:
Dim Key As RegistryKey = Nothing
Private Sub StringTableDialog_Load(sender As Object, e As EventArgs) Handles Me.Load
Select Case Me.RegistryHive
Case RegistryHive.ClassesRoot
Key = Registry.ClassesRoot
Case RegistryHive.CurrentConfig
Key = Registry.CurrentConfig
Case RegistryHive.CurrentUser
Key = Registry.CurrentUser
Case RegistryHive.LocalMachine
Key = Registry.LocalMachine
Case RegistryHive.Users
Key = Registry.Users
End Select
Try
Me.TextBox1.ReadOnly = True
With Key
If Me.TextBox1.AutoCompleteCustomSource.Count = 0 Then
Me.TextBox1.AutoCompleteCustomSource.AddRange(.Get SubKeyNames)
End If
End With
Me.TextBox1.ReadOnly = False
Catch ex As Exception
MsgBox(ex.Message)
End Try
End Sub