Listview所选项目设置时间 [英] Listview selected item set timing

查看:83
本文介绍了Listview所选项目设置时间的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的项目使用Windows应用程序(使用C#dotnet)

我有一个包含某些项目的列表框控件,当我单击按钮时,将从列表框中选择第一个项目,它将一个特定的时间间隔移动一个,我可以将每个项目的时间间隔从一个选定的项目提供给另一个项目,因此根据时间安排,所选项目将一个一个地移动.

如果您不懂此,请给我发邮件

这是完成我的项目的非常紧迫的任务.因此,任何人都请尽快发布.


问候
Vasanth

My project using Windows Application using C# dotnet

I have a listbox control with some items, when i click the button, from the list box first item will selected and it will moves one by one of particular timing gap, i can give the timing gap for each one item from one selected item to another item, so based on the timing the selected item will move one by one.

If you not understand this please mail me

This one is very urgent task to finish my project. So any one please post as soon as possible.


Regards
Vasanth

推荐答案

1)声明一个至少包含元素文本和时间的类:
1) Declare a class that contains the at least text of the elements and the timing:
class TimedListElement 
{
   public string caption {get;set;}
   public int timing {get;set;}
}


2)使用此类对象创建一个列表


2) Create a list with objects of this kind

List<TimedListelEment> elements = new List<TimedListElements>();
elements.Add(new TimedListElement(){caption = "Firts", timing=5});
elements.Add(new TimedListElement(){caption = "Second", timing=10});
elements.Add(new TimedListElement(){caption = "Third", timing=3});


3)将此列表提供给ListBox:


3) Feed the ListBox with this list:

yourListBox.DataSource = elements;


4)指定DisplayMember:


4) Specify DisplayMember:

yourListBox.DisplayMember = "caption";
yourListBox.ValueMember = "timing";


5)现在,您可以使用 SelectedValue [ ^ ]属性例如,计时.


5) Now, you can use the SelectedValue[^] property of the listbox to egt the timing.


在某些外部类文件(StaticClassFile)中声明静态变量
Declare on static variable in some external class file (StaticClassFile)
private static int selectedrow = 0;



形式
控制计时器.



In form
Take timer control.

private void timer1_Tick(object sender, System.EventArgs e)
{
StaticClassFile.selectedrow = StaticClassFile.selectedrow +1;
gridview1.SelectedRow=  StaticClassFile.selectedrow; 

}


这篇关于Listview所选项目设置时间的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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