473,385 Members | 2,044 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

Ho to set background color after upgrading from VB6

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.Sk inLockedColor)
Else
ctl.BackColor =
System.Drawing.ColorTranslator.FromOle(CurrSkin.Sk inRegColor)
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.

Nov 21 '05 #1
2 1270
Gungmas,

Directcast(ctl, textbox).

I hope this helps?

Cor
"Gungmas"
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.Sk inLockedColor)
Else
ctl.BackColor =
System.Drawing.ColorTranslator.FromOle(CurrSkin.Sk inRegColor)
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.

Nov 21 '05 #2
Thanks, that helped a lot!

"Cor Ligthert" wrote:
Gungmas,

Directcast(ctl, textbox).

I hope this helps?

Cor
"Gungmas"
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.Sk inLockedColor)
Else
ctl.BackColor =
System.Drawing.ColorTranslator.FromOle(CurrSkin.Sk inRegColor)
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.


Nov 21 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

6
by: Michael Foord | last post by:
http://www.voidspace.org.uk/python/articles/upgrading_python.html I've been looking at whether to upgrade immediately from Python 2.3 to Python 2.4 or postpone it. This is my first `major version...
4
by: erik | last post by:
Is it posssible to inherit the previous pages (parent pages) background image? Is there a script out there I could look at? Thanks
1
by: John D | last post by:
I am trying to change the background colour of either a div or a textarea with javascript, but am having problems. I have passed a hex colour value in the variable hval, and with the following...
11
by: Konrad Den Ende | last post by:
I have a function returning a string but the problem is that the color of it is blue which suits me well for some pages but not for others. Is it possible to "feel" what the color of the background...
5
by: Mike Owen | last post by:
Hi, I have just used the import Wizard to import a VS 2003 app to VS 2005. I have a lot of work to do to enable it to compile successfully with all the errors and warnings it gave me, but as a...
2
by: Dave Hughes | last post by:
Just noticed something rather annoying after upgrading my test box (a Linux server running DB2 UDB v8 for LUW) to fixpak 11 (for reference it was previously on fixpak 7). In the past I've relied...
6
by: JimLad | last post by:
Hi, We have a major ASP app that we are in the process of upgrading to ASP.NET 1.1 and probably on to ASP.NET 2.0 in the middle of next year. (We will also be upgrading to SQL2K5 at the same...
16
by: stevedude | last post by:
CSS newbie again. I have a problem trying to get coffee mug images within anchor tags to center with my link text for a vertical list menu. If I use the horizontal/vertical properties of...
10
by: VividWeb | last post by:
Hi. I am relatively new to CSS and HTML but have a basic understanding of most things. One of my backgrounds is not positioning correctly in IE 7 or AOL. The background behind the content...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.