|
-
Jun 15th, 2009, 03:32 PM
#1
Thread Starter
Member
[RESOLVED] Need help converting CSharp to VB.net
I have been trying to design a custom tabcontrol in vb.net used a codeproject example to develop the said tabcontrol but the example is in C# I have converted all parts and theres only one error i cant seem to work around could you guys help?
C# Code Code:
void ColorTabControl_ControlAdded(object sender, ControlEventArgs e)
{
if (e.Control.GetType() == typeof(TabPage))
{
e.Control.Font = new Font(e.Control.Font, e.Control.Font.Style & ~FontStyle.Bold);
}
}
VB Code That I think it is... Code:
Private Sub ColorTab_ControlAdded(ByVal sender As System.Object, ByVal e As System.Windows.Forms.ControlEventArgs) Handles MyBase.ControlAdded
' ERROR: 'is' expected \/
If e.Control.GetType() = typeOf(Tabpage) Then
e.Control.Font = New Font(e.Control.Font, e.Control.Font.Style & FontStyle.Bold)
End If
End Sub
Sorry if this is the wrong section since my result code will ve in vb thats why i posted it here.
Beginner: Java
Intermediate: VB.Net, C#, Delphi, Perl
Master: HTML, XHTML, PHP, JavaScript, Pascal, SCAR
-
Jun 15th, 2009, 03:59 PM
#2
Re: Need help converting CSharp to VB.net
Try
Code:
If TypeOf e.Control Is TabPage Then ....
Let us have faith that right makes might, and in that faith, let us, to the end, dare to do our duty as we understand it.
- Abraham Lincoln -
-
Jun 15th, 2009, 04:07 PM
#3
Re: Need help converting CSharp to VB.net
I wouldn't even bother to check what type of control it is.
ColorTab is a tabcontrol right? TabControls can only have 1 type of control added to them, and that is tabpages. If you try to add any control to a tabcontrol, that is not a tabpage, an exception will occur telling you what I am telling you. So the ControlAdded event of a tabcontrol WILL NEVER FIRE unless a tabpage was actually added to the tabcontrol, so there is no need to check that it is that type. It will always be a tabpage.
-
Jun 15th, 2009, 08:15 PM
#4
Re: [RESOLVED] Need help converting CSharp to VB.net
The 'keyword overlap' can be confusing.
The VB equivalent is:
Code:
Private Sub ColorTabControl_ControlAdded(ByVal sender As Object, ByVal e As ControlEventArgs)
If e.Control.GetType() Is GetType(TabPage) Then
e.Control.Font = New Font(e.Control.Font, e.Control.Font.Style And (Not FontStyle.Bold))
End If
End Sub
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|