Ho to set background color after upgrading from VB6

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I have used a generic funtion for setting background color in my VB6 code
like this:
For Each ctl In frm.Controls
sCtlType = TypeName(ctl)
If sCtlType = "TextBox" Or sCtlType = "ComboBox" Then
If ctl.Locked Then
ctl.BackColor = CurrSkin.SkinLockedColor
Else
ctl.BackColor = CurrSkin.SkinRegColor
End If
Else
ctl.BackColor = CurrSkin.SkinColor
End If
Next
When I convert it to .NET it looks like this (snippet):
If ctl.Locked Then
ctl.BackColor =
System.Drawing.ColorTranslator.FromOle(CurrSkin.SkinLockedColor)
Else
ctl.BackColor =
System.Drawing.ColorTranslator.FromOle(CurrSkin.SkinRegColor)
End If
I realize that the Locket property is now called ReadOnly (for TextBox) but
I can not use it directly because the ctl object
(System.Windows.Forms.Control) does not have that property.
How do I do this in .NET?
Is there a way to typecast the ctl object to a TextBox?
Any help greatly appreciated.
 
Gungmas,

Directcast(ctl, textbox).

I hope this helps?



Cor
"Gungmas"
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top