Link to home
Start Free TrialLog in
Avatar of alStatus
alStatus

asked on

How would you change the font color during run time in C#?

maze[xEntrance, 0] = "S";
             maze[xEntrance, 1] = "M";     //<----  how t0 change this "M" into another color?
             maze[xEntrance, 2] = " ";                      
             maze[left, 1] = " ";
Avatar of Mike Tomlinson
Mike Tomlinson
Flag of United States of America image

Pretty sure "maze" was just a String Array right?  It doesn't have a color associated with it; simply a value.  The coloring would be done by the CONTROL you use to display the values.  If you are using a Label then everything is the same color.  To get multiple colors you could display everything in a RichTextBox which allows you to include multiple formats and colors all in the same control.
Will all like values in the maze be the same color?  If not, then you'll need to associate a color with each cell in the maze which means you'd need an addition array or possibly store a class in the array instead of a straight string value.
Avatar of alStatus
alStatus

ASKER

Yep, its a string array. When the "M" moves in the array, id like the "M" be a different color then the Maze array. And The "F" be a different color, to symbol the foot print left behind. So go with the RichTextBox?
Definitely RichTextbox as that would be the easiest.  It's either that, or use separate Labels or TextBoxes for each cell in the maze.

If you post your current method that generates the output I can help you convert to the RichTextbox.
Not sure which function so added all functions.
MickyMouseMaze.zip
ASKER CERTIFIED SOLUTION
Avatar of Mike Tomlinson
Mike Tomlinson
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Great example! But, it does not print the right boarder on the maze is it because of one of the  property options, like it was for the label?
All elements should be printed just as before.  Most likely you just need to make the RichTextBox WIDER...  =)
Yep, had the RichTextBox size  = to 1303,729.
I changed the text to courier new, that worked.
Great demo, thanks man!