gpt4 book ai didi

c# - 将我当前的光标位置显示为当前行和当前列?

转载 作者:太空宇宙 更新时间:2023-11-03 19:17:28 25 4
gpt4 key购买 nike

我正在开发使用 RichtextBoxMenustrip 和更多控件的 Windows 窗体应用程序。

我已经完成了一些工作,但无法正常工作。当我的鼠标光标在 RichTextBox 中移动时,我想自动更改位置,就像在简单的记事本上那样。

我的位编码是....

我想要它,所以当我的鼠标光标移动时,它会改变我状态栏上的动态位置

private void sizeToolStripMenuItem_Click(object sender, EventArgs e)
{
int line = richTextBox1.GetLineFromCharIndex(richTextBox1.SelectionStart);
int column = richTextBox1.SelectionStart - richTextBox1.GetFirstCharIndexFromLine(line);
toolStripStatusLabel5.Text ="Line"+" "+ line.ToString();
toolStripStatusLabel6.Text = " Column" + " " + line.ToString();
toolStripStatusLabel3.Text= Cursor.Position.ToString(); // where is my mouse cursor at this Time like that x and y cordinate 330,334
}

最佳答案

每次按回车键时显示你的行。代码如下:::----

private void Key_Down(object sender, KeyEventArgs e)
{
if (e.KeyData == Keys.Enter)
{
int line = richTextBox1.GetLineFromCharIndex(richTextBox1.SelectionStart);
int column = richTextBox1.SelectionStart - richTextBox1.GetFirstCharIndexFromLine(line);

toolStripStatusLabel5.Text = "Line" + " " + line.ToString();
toolStripStatusLabel6.Text = " Column" + " " + column.ToString();
toolStripStatusLabel3.Text = Cursor.Position.ToString(); // where is my mouse cursor at this Time like that x and y cordinate 330,334
Update();
}
}

关于c# - 将我当前的光标位置显示为当前行和当前列?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15146693/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com