列表框项目如何 [英] list box item how to

查看:66
本文介绍了列表框项目如何的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的应用程序有2个我想要的列表框,当我单击列表框2的项目编号10时.
列表框1个选定项目=数字10,

my app have 2 list box i want when i click on list box2 item number 10.
list box1 selected item = number 10,
sorry for bad English.

推荐答案

如果要在ListBox2上选择具有相同索引的项目 ,请使用以下代码.选择了ListBox1之一.

Use the following code if you want to select on ListBox2 the item having the same index of the selected one of ListBox1.

private void listBox1_SelectedIndexChanged(object sender, System.EventArgs e)
{
   int cursel = listBox1.SelectedIndex;
   if ( cursel < ListBox2.Items.Count )
   {
     ListBox2.SetSelected(cursel, true);
   }
}


这篇关于列表框项目如何的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆