我的表单中有一个丰富的文本框、列表框和复选列表框以及一个按钮。富文本框已加载文本文件。我正在搜索富文本框中选中的列表框的字符串,并将找到的字符串的索引添加到列表框中。在鼠标双击错误列表的事件中,我将光标设置为字符串的特定索引位置。
现在,我计划在表单Next和以前的表单中再添加两个按钮。它将选择列表框和游标的下一项和前一项,应该指向该位置。如何做到这一点。也就是说,在单击下一步的按钮时,所选的项目应该是当前项的旁边,为此,我应该调用鼠标双击事件。
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);
}
}发布于 2012-02-23 14:44:30
不一定被认为是良好的实践,但如果您只是忽略发送方和事件,则可以使用“null”来调用任何事件。
https://stackoverflow.com/questions/9410166
复制相似问题