Value of type 'String' cannot be converted to 'System.Drawing.Color'

Value of type 'String' cannot be converted to 'System.Drawing.Color'

Post by jdn » Wed, 24 Jul 2002 03:42:55



Getting the above error from the following line:

lblWelcome.forecolor = "red"

where lblWelcome is a label control.

How are you supposed to change the text color?

TIA

jdn

 
 
 

Value of type 'String' cannot be converted to 'System.Drawing.Color'

Post by jdn » Wed, 24 Jul 2002 04:27:50


Never mind, solved it.  You use the fromName functionality, so:

lblWelcome.forecolor = system.drawing.color.fromname("red")

to do it.

jdn


> Getting the above error from the following line:

> lblWelcome.forecolor = "red"

> where lblWelcome is a label control.

> How are you supposed to change the text color?

> TIA

> jdn



 
 
 

1. Cannot implicitly convert type 'System.Windows.Forms.MouseEventHandler' to 'System.EventHandler'

I'm using Beta2 and am trying to pass MouseClick arguments rather than
the default arguements for the ListBox_Click event.  I think my code
is correct, but it throws this error:

Cannot implicitly convert type
'System.Windows.Forms.MouseEventHandler' to 'System.EventHandler'

Here is my code:

// I contruct the event in the Forms contructor area...
this.listBox.Click += new System.Windows.Forms.MouseEventHandler
this.listBox_Click);

//Ultimately, I want to use the event here:
private void listBox_Click(object sender,
System.Windows.Forms.MouseEventArgs e)
   {
      if (e.Button == MouseButtons.Right)
        {
           System.Windows.Forms.Control control = new
System.Windows.Forms.Control();
           control.CreateControl();
           this.contextMenu1.Show(control,Cursor.Position);
        }
   }

THANKS in advance for any help with this!  I'm thinking this is a bug
in Beta2???

2. RT311, DSL Modem, and Cables

3. Cannot implicitly convert type 'object' to 'System.Web.UI.WebControls.TextBox'

4. IT REALLY WORKS!

5. System.InvalidCastException: Cast from type 'DBNull' to type 'String' is not valid

6. System 6 & SCSI partitions

7. OlderGames announces new CD32 product! (fwd)

8. Error: Cannot cast 'dbnull' into type 'string'

9. Cast from type 'DBNull' to type 'String' is not valid

10. Error - Cast from type 'DBNull' to type 'String' is not valid

11. An unhandled exception of type 'System.ArithmeticException' occurred in system.drawing.dll

12. Error when converting MaximumValue property of 'RangeValidator7' to type 'Date'.