Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7035371
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T01:17:47+00:00 2026-05-28T01:17:47+00:00

So I am using a C# WebBrowser control and am trying to convert a

  • 0

So I am using a C# WebBrowser control and am trying to convert a string into an HTML/CSS rainbow. Currently I simply randomly generate 1000 colors in hex format and iterate through each char in the string adding a span style color:(hex value) for each char. It works but I would like the colors to merge together for a more rainbow effect. Is this possible? Here is my current function:

    public static string Rainbow(string text)
    {
        int numColors = 1000;
        var colors = new List<string>();
        var random = new Random();
        for (int i = 0; i < numColors; i++)
        {
            colors.Add(String.Format("#{0:X6}", random.Next(0x1000000)));
        }

        string rainbow = "";
        int index = 0;
        foreach (char c in text)
        {
            rainbow += String.Format("<span style='color: {0};'>{1}</span>", colors[index], c.ToString());

            if (index > numColors)
                index = 0;
            else
                index++;
        }

        return rainbow;
    }
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-28T01:17:48+00:00Added an answer on May 28, 2026 at 1:17 am

    Simple; don’t use Random!

    Something like this may help you get started:

    for (int i = 0; i < 256; i++)
        {
            colors.Add(String.Format("#{0:X2}{1:X2}00", i, 255-i));
        }
    

    to fade from green to red in 255 steps.

    HTH!

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

In WPF, we are using a WebBrowser control to view HTML content. When we
I am currently working on a project where I am using a WebBrowser control
I am trying to convert a WPF WebBrowser control to a WinForms WebBrowser control
I'm currently using System.Windows.Forms webbrowser control to automate a webpage. Everything works fine to
Currently i'm developing an web automation system using WebBrowser control and AxWebBrowser control in
Possible Duplicate: How to disable “Security Alert” window in Webbrowser control I'm currently using
I'm trying to automate in a WinForm using a WebBrowser control to navigate and
I'm trying to use a .Net WebBrowser control to log into a website and
I am trying to open HTML file in WebBrowser window of WPF using MVVM
I'm trying to use an invisible WebBrowser control to print a very simple HTML

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.