Parham.D
جمعه 14 تیر 1387, 18:12 عصر
پست قبلي خراب شد. من را ببخشيد ، اين اولين پست مستقيم من هست !! دوستان يك كنترل TabControl دارم كه در حال اجرا برنامه به اون TabPage اضافه ميكنم و به هر TabPage يك RichTextBox اضافه ميكنم. با كمك For Each به هر RichTextBox دسترسي پيدا ميكنم و آن را تغيير ميدهم. مشكل من اين هست كه نميتونم براي هر RichTextBox رويداد تعريف كنم. اگر با حالت WithEvent بخواهم از For Each استفاده كنم به من پيغام خطا ميده. لطفا كمك كنيد.
PrivateWithEvents GetControl AsNew RichTextBox
For Each GetControl In Me.TabPages.SelectedTab.Controls
If TypeOf GetControl Is RichTextBox Then
If GetControl.Name = "NotePage1" Then
If BoldTSB.Checked = False Then
BoldTSB.Checked = True ' Push the bold button on
NotePage1.SelectionFont = New Font(NotePage1.Font.FontFamily, NotePage1.Font.Size, FontStyle.Bold
Else
BoldTSB.Checked = False ' Push the bold button off.
NotePage1.SelectionFont = New Font(NotePage1.Font.FontFamily, NotePage1.Font.Size, FontStyle.Regular)
End If
Else
If BoldTSB.Checked = False Then
BoldTSB.Checked = True ' Push the bold button on
GetControl.SelectionFont = New Font(GetControl.Font.FontFamily, GetControl.Font.Size, FontStyle.Bold)
Else
BoldTSB.Checked = False ' Push the bold button off
GetControl.SelectionFont = New Font(GetControl.Font.FontFamily, GetControl.Font.Size, FontStyle.Regular)
End If
End If
End If
Next
Error 1 Loop control variable cannot be a property or a late-bound indexed array.
PrivateWithEvents GetControl AsNew RichTextBox
For Each GetControl In Me.TabPages.SelectedTab.Controls
If TypeOf GetControl Is RichTextBox Then
If GetControl.Name = "NotePage1" Then
If BoldTSB.Checked = False Then
BoldTSB.Checked = True ' Push the bold button on
NotePage1.SelectionFont = New Font(NotePage1.Font.FontFamily, NotePage1.Font.Size, FontStyle.Bold
Else
BoldTSB.Checked = False ' Push the bold button off.
NotePage1.SelectionFont = New Font(NotePage1.Font.FontFamily, NotePage1.Font.Size, FontStyle.Regular)
End If
Else
If BoldTSB.Checked = False Then
BoldTSB.Checked = True ' Push the bold button on
GetControl.SelectionFont = New Font(GetControl.Font.FontFamily, GetControl.Font.Size, FontStyle.Bold)
Else
BoldTSB.Checked = False ' Push the bold button off
GetControl.SelectionFont = New Font(GetControl.Font.FontFamily, GetControl.Font.Size, FontStyle.Regular)
End If
End If
End If
Next
Error 1 Loop control variable cannot be a property or a late-bound indexed array.