Click here to Skip to main content
15,895,142 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
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
Posted
Updated 9-Aug-12 23:13pm
v2
Comments
Zoltán Zörgő 10-Aug-12 5:22am    
So you want to be able to go from element1 to element2 in let's say 5s, bot from element2 to element3 in 10s, ant to the next in 3s, and so on? You want to be able to specify different timing for every element? What is the datasource of your listbox?
vasanthkumarmk 10-Aug-12 5:25am    
i don't have a datasource,i can add item directly.......

1) Declare a class that contains the at least text of the elements and the timing:
C#
class TimedListElement 
{
   public string caption {get;set;}
   public int timing {get;set;}
}

2) Create a list with objects of this kind
C#
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) Feed the ListBox with this list:
C#
yourListBox.DataSource = elements;

4) Specify DisplayMember:
C#
yourListBox.DisplayMember = "caption";
yourListBox.ValueMember = "timing";

5) Now, you can use the SelectedValue[^] property of the listbox to egt the timing.
 
Share this answer
 
v3
Comments
vasanthkumarmk 10-Aug-12 5:58am    
any other solutions?
Zoltán Zörgő 12-Aug-12 8:22am    
Actually you can store your elements in an xml (see: http://www.hookedonlinq.com/LINQtoXML5MinuteOverview.ashx) or in the app.config file also (see: http://www.codeproject.com/Articles/32490/Custom-Configuration-Sections-for-Lazy-Coders). This way you don't need to change the code if the elements need to be changed, and you don't need to add the elements "my hand".
Volynsky Alex 10-Aug-12 6:09am    
But it's not a bad answer, isn't it?
vasanthkumarmk 10-Aug-12 6:35am    
really thanks for your code..
Declare on static variable in some external class file (StaticClassFile)
C#
private static int selectedrow = 0;


In form
Take timer control.
C#
private void timer1_Tick(object sender, System.EventArgs e)
{
StaticClassFile.selectedrow = StaticClassFile.selectedrow +1;
gridview1.SelectedRow=  StaticClassFile.selectedrow; 

}
 
Share this answer
 
v2
Comments
vasanthkumarmk 10-Aug-12 5:30am    
k thanks, i can try it..

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900