gpt4 book ai didi

c# - 事件的嵌套触发

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

我的表单中有一个富文本框、列表框和选中的列表框以及一个按钮。富文本框已加载文本文件。我在富文本框中搜索选中列表框的字符串,并将找到的字符串的索引添加到列表框中。在错误列表的鼠标双击事件中,我将光标设置到字符串的特定索引位置。

现在我计划在 Next 和 previous 表单中再添加两个按钮。这将选择列表框的下一个和上一个项目,光标应指向该位置。怎么做。也就是说,在单击下一个按钮时,所选项目应该是当前项目的下一个,为此我应该调用鼠标双击事件。

 private void lstErrorList_MouseDoubleClick(object sender, MouseEventArgs e)
{
//rtbFileDisplay.Cursor = Cursors.WaitCursor;
MessageBox.Show(lstErrorList.SelectedIndex.ToString());

int val;
string val1 = lstErrorList.Text;
val1 = val1.Remove(0, val1.Length - 8);
string replacement = Regex.Replace(val1, @"\t|\n|\r|[a-zA-Z]","");
val = Convert.ToInt32(replacement);
rtbFileDisplay.Select(val, 0);

rtbFileDisplay.Focus();

}
private void btnNextError_Click(object sender, EventArgs e)
{
if (lstErrorList.Items.Count != 0)
{
if (lstErrorList.SelectedIndex != lstErrorList.TopIndex)
lstErrorList.SelectedIndex++;
//lstErrorList.SelectedItem = int.Parse(lstErrorList.SelectedItem + 1);

}
}

最佳答案

不一定被认为是好的做法,但如果您只是忽略它们,您可以用“null”代替 sender 和 eventargs 来调用任何事件。

关于c# - 事件的嵌套触发,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9410166/

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