这是关于C#中的SelectedIndex和SelectedItem的问题
privatevoidtoolLetter_Click(objectsender,EventArgse){this.SuspendLayout();if(toolLett...
private void toolLetter_Click(object sender, EventArgs e)
{
this.SuspendLayout();
if(toolLetter.SelectedIndex!=-1)
{
Single myFontSize = System.Convert.ToString(this.toolLetter.SelectedItem);
if (richTextBox1.SelectionFont != null)
{
System.Drawing.Font currentFont = richTextBox1.SelectionFont;
System.Drawing.FontStyle newFontStyle;
bool currenFontBold = richTextBox1.SelectionFont.Bold;
bool currenFontItalic = richTextBox1.SelectionFont.Italic;
bool currenFontUnderLine = richTextBox1.SelectionFont.Underline;
newFontStyle = (currenFontBold ? FontStyle.Bold : FontStyle.Regular) | (currenFontUnderLine ? FontStyle.Underline : FontStyle.Regular) | (currenFontUnderLine ? FontStyle.Italic : FontStyle.Regular);
richTextBox1.SelectionFont = new Font(currentFont.FontFamily, myFontSize, newFontStyle);
}
else
{
int myPos, myLen;
myPos = richTextBox1.SelectionStart;
myLen = richTextBox1.SelectionLength;
}
}
}
运行错误是:
错误 1 “System.Windows.Forms.ToolStripButton”不包含“SelectedIndex”的定义,并且找不到可接受类型为“System.Windows.Forms.ToolStripButton”的第一个参数的扩展方法“SelectedIndex”(是否缺少 using 指令或程序集引用?) F:\C#工作站\Wednesday\Wednesday\Form5.cs 98 27 Wednesday
错误 2 “System.Windows.Forms.ToolStripButton”不包含“SelectedItem”的定义,并且找不到可接受类型为“System.Windows.Forms.ToolStripButton”的第一个参数的扩展方法“SelectedItem”(是否缺少 using 指令或程序集引用?) F:\C#工作站\Wednesday\Wednesday\Form5.cs 100 77 Wednesday 展开
{
this.SuspendLayout();
if(toolLetter.SelectedIndex!=-1)
{
Single myFontSize = System.Convert.ToString(this.toolLetter.SelectedItem);
if (richTextBox1.SelectionFont != null)
{
System.Drawing.Font currentFont = richTextBox1.SelectionFont;
System.Drawing.FontStyle newFontStyle;
bool currenFontBold = richTextBox1.SelectionFont.Bold;
bool currenFontItalic = richTextBox1.SelectionFont.Italic;
bool currenFontUnderLine = richTextBox1.SelectionFont.Underline;
newFontStyle = (currenFontBold ? FontStyle.Bold : FontStyle.Regular) | (currenFontUnderLine ? FontStyle.Underline : FontStyle.Regular) | (currenFontUnderLine ? FontStyle.Italic : FontStyle.Regular);
richTextBox1.SelectionFont = new Font(currentFont.FontFamily, myFontSize, newFontStyle);
}
else
{
int myPos, myLen;
myPos = richTextBox1.SelectionStart;
myLen = richTextBox1.SelectionLength;
}
}
}
运行错误是:
错误 1 “System.Windows.Forms.ToolStripButton”不包含“SelectedIndex”的定义,并且找不到可接受类型为“System.Windows.Forms.ToolStripButton”的第一个参数的扩展方法“SelectedIndex”(是否缺少 using 指令或程序集引用?) F:\C#工作站\Wednesday\Wednesday\Form5.cs 98 27 Wednesday
错误 2 “System.Windows.Forms.ToolStripButton”不包含“SelectedItem”的定义,并且找不到可接受类型为“System.Windows.Forms.ToolStripButton”的第一个参数的扩展方法“SelectedItem”(是否缺少 using 指令或程序集引用?) F:\C#工作站\Wednesday\Wednesday\Form5.cs 100 77 Wednesday 展开
1个回答
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询