|
Have Fun
Never forget it
|
|
|
|
|
I have a collection class which wraps a generic List. This collection has two methods say, MoveUp and MoveDown. When MoveUp is called with an item, the supplied item will be moved one location down in the collection. There are events available for these operations.
I have a custom control which wraps ListBox. This control has subscribed for the events in my collection class. So when there is MoveUp or MoveDown in the collection, this control will get notifications.
Now I need to rearrange the listbox items according to the collection items when something moves up or down. I am doing this by removing all listbox items and adding it again which seems to be a bad idea and also it flickers the control.
Is there any better way to do this ?
|
|
|
|
|
What about swapping them?
Move up
Object o = lb1.items(lb1.selectedindex -1 )
lb1.items(lb1.selectedindex -1 ) = lb1.items(lb1.selectedindex)
lb1.items(lb1.selectedindex) = o
Obviously needs a bit of tinkering and checking for top/bottom, but you get the gist.
Bob
Ashfield Consultants Ltd
|
|
|
|
|
Thanks Bob, I will give a try
|
|
|
|
|
Remove the selected one, and re-insert it one position higher (don't forget to account for being at the top or bottom of the listbox). Also, you can avoid flickering if you turn off updates, remove/insert, and then turn updates back on.
"Why don't you tie a kerosene-soaked rag around your ankles so the ants won't climb up and eat your candy ass..." - Dale Earnhardt, 1997 ----- "...the staggering layers of obscenity in your statement make it a work of art on so many levels." - Jason Jystad, 10/26/2001
|
|
|
|
|
John Simmons / outlaw programmer wrote: Remove the selected one, and re-insert it one position higher (don't forget to account for being at the top or bottom of the listbox
Fair idea. Thanks John
John Simmons / outlaw programmer wrote: if you turn off updates, remove/insert, and then turn updates back on.
I can't find how to turn off updates. Do you mean to calling SuspendLayout() and ResumeLayout() ?
|
|
|
|
|
It's actually BeginUpdate() and EndUpdate() ...
"Why don't you tie a kerosene-soaked rag around your ankles so the ants won't climb up and eat your candy ass..." - Dale Earnhardt, 1997 ----- "...the staggering layers of obscenity in your statement make it a work of art on so many levels." - Jason Jystad, 10/26/2001
|
|
|
|
|
Thanks. I will take a look at that
|
|
|
|
|
Hi,
i'm Trying to Implement the Ctrl+S (save)
Do i need to Monitor the KeyPress Events and check The Last Two Keys Pressed
or there is an easer way ( a Buit -In )
Have Fun
Never forget it
|
|
|
|
|
private void form_KeyDown(object sender, KeyEventArgs e)
{
if (e.Control && e.KeyCode == Keys.S)
|
|
|
|
|
Thanks a Lot
Have Fun
Never forget it
|
|
|
|
|
KeyUp's (or KeyDown's) KeyEventArgs has a Control property, then just check KeyCode for S.
|
|
|
|
|
If you have a menu on the form, just set the shortcut to Ctrl+S on your Save item.
|
|
|
|
|
Wow, Thanks A lot
i Never Knew this Feature Exsits
Thanks Agian
Have Fun
Never forget it
|
|
|
|
|
I What some UserControl
each with a Menu
the Funny thing is that it always selects the last and perform the Action on it
any IDEA
Have Fun
Never forget it
|
|
|
|
|
You can't have the same shortcut assigned to different actions. You need to supply a different shortcut.
|
|
|
|
|
Thanks
Have Fun
Never forget it
|
|
|
|
|
Hi,
i'm trying to Lock The Form so that the user would'nt be able to Move it
How can i Do It, i'd tried a variaty of properties, non helped
any Suggestions
Have Fun
Never forget it
|
|
|
|
|
Set the FormBorderStyle property to FormBorderStyle.None
Giorgi Dalakishvili
#region signature
my articles
#endregion
|
|
|
|
|
Thanks A Lot
I Never Thought to Try This Thanks Again
Have Fun
Never forget it
|
|
|
|
|
Or if you want to keep the titlebar and other stuff:
class Form1
{
Point pos;
public Form1()
{
InitializeComponent();
this.Pos=new Point(this.Left,this.Top);
this.Move+=Form1_Move;
}
void Form1_Move(object sender, EventArgs e)
{
this.Left=pos.X;
this.Top=pos.Y;
}
}
|
|
|
|
|
Thanks
Have Fun
Never forget it
|
|
|
|
|
I want to define the object type in the ArrayList to be string - i dont want to leave is as Object.
How to do it ?
|
|
|
|
|
You can't do this in ArrayList. Use List<string> instead
|
|
|
|
|
You could just use a string[] array, or use List<string>...
"Why don't you tie a kerosene-soaked rag around your ankles so the ants won't climb up and eat your candy ass..." - Dale Earnhardt, 1997 ----- "...the staggering layers of obscenity in your statement make it a work of art on so many levels." - Jason Jystad, 10/26/2001
|
|
|
|