0

テキストボックスがあり、名前が Rich付けられていますtextBox1

これを試すと:

                    textBox1.AppendText(value);
                    textBox1.SelectionColor = Color.Red;

これにRedは下線が引かれ、エラーが表示されます:

Error 2 'string' does not contain a definition for 'Red' and no extension method 'Red' accepting a first argument of type 'string' could be found (are you missing a using directive or an assembly reference?) Form1.cs 73 57

4

1 に答える 1

2

Colorフォームに、タイプがという名前のフィールドまたはプロパティがありstringますか? その場合、「色」はタイプColor.Redではなくそのフィールドまたはプロパティを参照します。System.Drawing.Color

System.Drawing名前空間を指定することで、参照を明確にすることができます。

textBox1.SelectionColor = System.Drawing.Color.Red;
于 2012-10-23T20:08:12.380 に答える