c# 获取textbox里某个字符的字体?textbox存在多种字体,如何按照字符一一获取?求高人解答
利用paragraph.Characters(i).Font.Name方法获取到的字体是错误的,利用这个方法paragraph.Characters(i).Font.Na...
利用paragraph.Characters(i).Font.Name 方法获取到的字体是错误的,利用这个方法paragraph.Characters(i).Font.NameFarEast 遇到英文的的情况是错误的
foreach (PowerPoint.Shape shape in allShapes) //所有text控件
{
foreach (PowerPoint.TextRange paragraph in shape.TextFrame.TextRange.Paragraphs())
{
for (int i = 1; i <= paragraph.Length; i++)
{
Console.WriteLine(paragraph.Characters(i).Text + ": " + paragraph.Characters(i).Font.Name + ", " + paragraph.Characters(i).Font.Size)
}
}
} 展开
foreach (PowerPoint.Shape shape in allShapes) //所有text控件
{
foreach (PowerPoint.TextRange paragraph in shape.TextFrame.TextRange.Paragraphs())
{
for (int i = 1; i <= paragraph.Length; i++)
{
Console.WriteLine(paragraph.Characters(i).Text + ": " + paragraph.Characters(i).Font.Name + ", " + paragraph.Characters(i).Font.Size)
}
}
} 展开
展开全部
textBox1中是字符串例如“adsadasdasdnm”
textBox2中是要找的字符串例如“sa”
int index = 0;
private void button2_Click(object sender, EventArgs e)
{
index = textBox1.Text.IndexOf(textBox2.Text, index);
if (index < 0)
{
index = 0;
textBox1.SelectionStart = 0;
textBox1.SelectionLength = 0;
MessageBox.Show("已到结尾");
return;
}
textBox1.SelectionStart = index;
textBox1.SelectionLength = textBox2.Text.Length;
index = index + textBox2.Text.Length;
textBox1.Focus();
}
textBox2中是要找的字符串例如“sa”
int index = 0;
private void button2_Click(object sender, EventArgs e)
{
index = textBox1.Text.IndexOf(textBox2.Text, index);
if (index < 0)
{
index = 0;
textBox1.SelectionStart = 0;
textBox1.SelectionLength = 0;
MessageBox.Show("已到结尾");
return;
}
textBox1.SelectionStart = index;
textBox1.SelectionLength = textBox2.Text.Length;
index = index + textBox2.Text.Length;
textBox1.Focus();
}
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询