473,698 Members | 2,192 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Setting table cell colors?

Hi all,

I need to set some table cells which I am adding from code.

I am using;

cell.backcolor = cell.backcolor. white

for example to set it to white - this is all very well and good for a
'named' colour - but how do I set this for #d4c5db as an example? I have
many colours which I need to enter the HTML hash number for rather than a
named color.

I looked at the RGB, but I dont *think* that will work completely as I'm
using colours which are not always in the 256 colour range, I just I'd also
have to set the saturation, brightness and hue, but I am unsure what to
enter for these as:

cell.backcolor. getsaturation

for example - has a type of 'single' I have no idea what this is, it doesnt
seem to allow me to say = 210 or (210)...

Any help would be appreciated, I guess I was hoping that I could just have
something like:

cell.backcolor = cell.backcolor( #d4c5db)

which would have been nice!

Regards

Rob
Nov 18 '05 #1
3 2172
Ok - so I realised that the html colors are hex, and that if I convert the
hex to dec I can then do what I want...so...

I made the following function:
Function HexToDec(ByVal Hex As String) As Color
' Declare variables
Dim strHexRed As String
Dim strHexGreen As String
Dim strHexBlue As String
Dim strDecRed As String
Dim strDecGreen As String
Dim strDecBlue As String

' Remove # character
If Left(Hex, 1) = "#" Then
Hex = Right(Hex, (Len(Hex) - 1))
End If

' Fix length of hex color to 6 characters
If Len(Hex) > 6 Then
Hex = Left(Hex, 6)
End If

' Set RGB hex values
strHexRed = Left(Hex, 2)
strHexGreen = Mid(Hex, 3, 2)
strHexBlue = Right(Hex, 2)

' Set RGB dec values
strDecRed = CLng("&H" & strHexRed)
strDecGreen = CLng("&H" & strHexGreen)
strDecBlue = CLng("&H" & strHexBlue)

' Return colour to calling code
Return (Color.FromArgb (strDecRed, strDecGreen, strDecBlue))
End Function
Which I can now call like thus:

cell.backcolor = HexToDec("#d4c5 db")
or
cell.backcolor = HexToDec("d4c5d b")

Seems to work well - if anyone has better solutions I'm open to suggestions
:o)

Regards

Rob
Nov 18 '05 #2
why not use thi

Control.BackCol or = Color.FromName( "#d4c5db"

HT

Trevor Benedict R
Nov 18 '05 #3
"Trevor Benedict R" wrote ...
Control.BackCol or = Color.FromName( "#d4c5db")


Hi Trevor...erm... .you gotta be shittin' me? Does that actually work! I
assumed that the FromName would represent the names of the colours built
into VS - ie, White, Black, Red, Green and so on.....

LOL - oh well, it was fun writing my useless function! :o)

Regards

Rob
Nov 18 '05 #4

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

Similar topics

3
73716
by: yukatan | last post by:
let's say this is a html table, how can i get the string value contained in the X cell ? --------------------- | | | | --------------------- | | | | --------------------- | X | | | ---------------------
7
10441
by: John A. | last post by:
Hello all! I've got a big bunch of pages using tables for layout. Eventually I'll get them set up with more modernized code, but in the meantime I'd like to slip in a little quick holiday decoration. I'd like to insert a table cell with a fixed width (as much as such things can be fixed) and a repeating garland background so as to show up along the left side of the table, repeating down its length. Our site has a couple thousand...
2
3227
by: Seth | last post by:
How can I hide an entire row of a table if one of the cells in that row is equal to a value drop down box value. My goal is to have a filtered table so that each cell in each row determines if it should be hidden by drop down boxes. Thanks for your help.
4
1793
by: Gary Hasler | last post by:
I have a full page of thumbnails linked to home plan pages. I'm adding a mouseover/mouseout effect to the table cells, plus a onclick event to permanently set the cell background to indicate the user's latest choice. This is in addition to the normal A HREF link, and seems to work fine. I set up anchors (A name="") on the thumbnail page, and the "Back to Plans" link from the home plan page contains a hash (#) to scroll the page down and...
0
2020
by: Sugapablo | last post by:
I'm using Firefox right now, and even when I check "File -> Page Setup -> Print backgrounds and colors" I can't get table cell colors to print. Do browsers just not do it? Is it a Mozilla problem? Is there a way to print them, either by HTML/CSS coding or by printer/browser settings? -- http://www.sugapablo.net <--personal | http://www.sugapablo.com <--music ]
8
11252
by: Jeff | last post by:
ASP.NET 2.0 I'm wondering how to set the color of a visited HyperLinkField (the link text) in a GridView?? Here is the markup of the HyperLinkField I have problems with: <asp:HyperLinkField HeaderText="Subject" Text="Subject" DataTextField="Subject" DataNavigateUrlFields="Id" DataNavigateUrlFormatString="~/Templates/View.aspx?id={0}" HeaderStyle-CssClass="columnStyle" ItemStyle-CssClass="columnStyle" />
1
3170
by: vp.softverm | last post by:
hi all . Am facing problem with the date picker. when i click on date picker in a popup window. the date table is opened in the middle of the pop up window. and it is unable to scroll with the pop up window .
1
3334
by: nirmala26 | last post by:
Hi All, I am using C#.net to develop a web application. I have a gridview and a table displaying two different lists of data. I want to have the backcolor of the cell (of both gridview and table) to blink between two colors, say for example the cell background color must blink (two colors using yellow, green). Is this possible ? I am able to only set the backcolor property with just one value. Can anyone help me with some ideas on how...
0
8603
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
9026
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
8893
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8861
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
7723
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
4366
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
3045
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
2328
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2001
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.