 |
|
 |
Hello! I have problem with drag and drop items between groups. Index of items don't depend from groups and when I want to drag item to another group then items are being reordered in all groups. How can I fix this problem?
|
| Sign In·View Thread·PermaLink | |
|
|
|
 |
|
|
 |
|
|
 |
|
 |
Hi men! Great work , but i woild like use your snippet in CheckedListBox... Can Someone tell me HOW TO? THNX
|
| Sign In·View Thread·PermaLink | 2.00/5 |
|
|
|
 |
|
 |
I have seen the code, its great ! can anyone help me, I need to develop a app where there is a tree control and a list view control. In list view there are two columns filled and the third one is empty column. what i need to do is to drag the item from tree control and put it in the third blank column of the listView....using C#. pls help me.
thanks in advance !
|
| Sign In·View Thread·PermaLink | 1.00/5 |
|
|
|
 |
|
 |
If the DragAndDropManager is used inside an UserControl inside a MMC 3.0 IFormViewControl the dragged item is always at position 0,0 inside the ListView (relative to the ListView). The MouseUtilities class does not return the mouse position in the same way as inside a normal window.
I seriously need help...
modified on Tuesday, April 22, 2008 9:50 AM
|
| Sign In·View Thread·PermaLink | 5.00/5 |
|
|
|
 |
|
 |
Hi..i'm new in c#. i want to use this drag and drop but i don't know how exactly to use it. Can someone explain to me plz...
|
| Sign In·View Thread·PermaLink | |
|
|
|
 |
|
 |
Just an idea, not sure if this is the right way of going about it, but i wanted a custome event that i could use after the reorder had taken place.
public delegate void AfterRowReorderHandler(object sender, EventArgs e); public event AfterRowReorderHandler AfterRowReorder;
protected virtual void OnAfterRowReorder(EventArgs e) { AfterRowReorder(this, new EventArgs()); }
OnAfterRowReorder(new EventArgs());
then in my main form
private void lstColumns_AfterRowReorder(object sender, EventArgs e) { table.TableItems = sortArrayList(); updatePreview(); }
|
| Sign In·View Thread·PermaLink | 2.00/5 |
|
|
|
 |
|
|
 |
|
 |
Hi,
I downloaded and tessted the code, but I realized that it doesn´t works if i set View property to View.LargeIcon... Instead of reordering items, the moved item always goes to the end of the listview.
Is there any way for fix that bug??
Thank´s
Lucio fuera!!!
|
| Sign In·View Thread·PermaLink | |
|
|
|
 |
|
 |
Sorry but I don't have time at the moment to add that functionality. If you want to write it yourself then send it to me and I'll post it onto the article.
|
| Sign In·View Thread·PermaLink | |
|
|
|
 |
|
 |
I really want to thank you for this useful article. I really need to be able to perform reordering on my listview in Large Icon view. Has somebody found a way to do it? I have searched a lot but I didn't find anything... 
THKs
|
| Sign In·View Thread·PermaLink | |
|
|
|
 |
|
 |
I had a quick look at implementing this for the large icon view. I think to make this work properly your going to have to provide a sorting algorithm specifically for the behaviour the control exhibits with in large icon view. I'm very sorry but I really don't have the time at the moment to look into this further, so your going to have to do it yourself. The good news is that all the changes are in the OnDragDrop method, everything else should remain the same.
David
|
| Sign In·View Thread·PermaLink | 2.00/5 |
|
|
|
 |
|
 |
I used a combination of Items.Remove, and Items.Insert with cloned ListViewItems to accomplish this. There is a bug in the ListView - as long as you do YourListView.Alignment = ListViewAlignment.Default and then YourListView.Alignment = ListViewAlignment.Top (Or left - whichever you are using) then it will not only correctly reorder everything visually, but within the indexing as well.
The code is too much to paste in here...
Eric Smith
|
| Sign In·View Thread·PermaLink | |
|
|
|
 |
|
 |
Altough i didn't use this code but one from an MS KB article, (http://support.microsoft.com/kb/822483/en-us)
I got sorting with Large icon working by adding a Class that inplements IComparer that comparers the ListViewItems index.
public class Compare : System.Collections.IComparer { int System.Collections.IComparer.Compare(object x, object y) { ListViewItem itemx = x as ListViewItem; ListViewItem itemy = y as ListViewItem;
if (itemx == null || itemy == null) return 0;
return itemx.Index - itemy.Index; }
-- modified at 3:43 Monday 19th June, 2006
|
| Sign In·View Thread·PermaLink | 5.00/5 |
|
|
|
 |
|
 |
This bug is really annoying. Try this : after applying your indexes to items.
yourlistview.View = View.Details yourlistview.View = View.LargeIcon Isn´t a final solution, but is better than nothing.:(
ntiago
|
| Sign In·View Thread·PermaLink | |
|
|
|
 |
|
 |
Using this solution, what is needed to extend the listbox to scroll up or down while dragging an item? Currently if the listbox is shorter than the list of items in details view, you can only drag to the limit of the drawn area.
Thanks for any help, jay
|
| Sign In·View Thread·PermaLink | |
|
|
|
 |
|
 |
I've got something functional on this, but its a filthy hack and somewhat jumpy. I included some synthetic variables to make my train(wreck) of thought easier to follow.
protected override void OnDragOver(DragEventArgs drgevent) { base.OnDragOver (drgevent); System.Drawing.Point p = this.PointToClient(new System.Drawing.Point (Cursor.Position.X, Cursor.Position.Y)); int topBound = this.ClientRectangle.Top + this.TopItem.Bounds.Height; int bottomBound = this.ClientRectangle.Bottom; int itemsVisible = (this.ClientRectangle.Height/this.TopItem.Bounds.Height) -1;
if (p.Y > (bottomBound)) { int moveTo = this.TopItem.Index + (itemsVisible); this.EnsureVisible(moveTo); } else if (p.Y < (topBound)) { int moveTo = this.TopItem.Index - (itemsVisible); if (moveTo < 0) moveTo = 0; this.EnsureVisible(moveTo); } }
Someone please come up with something better?  Thanks, jay
|
| Sign In·View Thread·PermaLink | |
|
|
|
 |
|
 |
To enable scrolling try adding the following 2 lines in the drag over.
protected override void OnDragOver(DragEventArgs e) { if(!this.AllowRowReorder) { e.Effect = DragDropEffects.None; return; } if(!e.Data.GetDataPresent(DataFormats.Text)) { e.Effect = DragDropEffects.None; return; } Point cp = base.PointToClient(new Point(e.X, e.Y)); ListViewItem hoverItem = base.GetItemAt(cp.X, cp.Y); if(hoverItem==null) { e.Effect = DragDropEffects.None; return; } foreach(ListViewItem moveItem in base.SelectedItems) { if(moveItem.Index==hoverItem.Index) { e.Effect = DragDropEffects.None; hoverItem.EnsureVisible(); //<--Code added return; } } base.OnDragOver(e); String text = (String)e.Data.GetData(REORDER.GetType()); if(text.CompareTo(REORDER)==0) { e.Effect = DragDropEffects.Move; hoverItem.EnsureVisible(); //<--Code added
} else { e.Effect = DragDropEffects.None; } }
|
| Sign In·View Thread·PermaLink | |
|
|
|
 |
|
 |
Lads,
thanks very much for your input, it's greatly appreciated . I've updated the article and its downloads to support scrolling and it should be available on the site in a few days.
David
|
| Sign In·View Thread·PermaLink | 5.00/5 |
|
|
|
 |
|
 |
Howdy, I've emplemented your code and the code from
http://www.c-sharpcorner.com/Code/2002/May/MultiColumnListViewSorting.asp
to try and sort a listview table by row AND column. What I'm looking to do is allow the user to sort data in a listview control by clicking onto the column header along with allowing the user to move data around a whole row at a time. The implementation is as a new form control that I drag drop onto my form and then set properties via the .NET ide. The thing is this, I can do only one or the other. Allow me to explain. I have three tables, one is set to sort via row another is set to sort via column and one is set to sort via row and column. The row sortable table works just fine. The column sortable table works just fine. However, the row and column sortable table only allows me to sort via column.
I can send the control's source code to you if you wish.
Update: BTW..further testing has shown that I can sort via row in the third table type if I don't sort via column. Once I sort via column, I cannot sort via row and can only sort via column. Further testing showed that if I comment out the line of code where the ListViewItemSorter is set in the column sortable code, I can sort via row even after sorting via column. I believe this shows some kind of incompatability between the row and column sorting code centered around the ListViewItemSorter. Hope this extra info helps.
Thanks in advance!
Update: Nevermind.. I figure it out. It's a friggin hack but it works. I save the ListViewSorter as a IComparer type before I do the column sort, then after the column sort I set it back to it's original value. Yea it's a hack but it wurks fo me.
|
| Sign In·View Thread·PermaLink | |
|
|
|
 |
|
 |
Bakutotsu,
I'm glad to hear you've sorted your problem out, and in my experience a hack is simply a state of mind You should post the Control as an article, I'm sure theres a lot of people would appreciate it.
David
|
| Sign In·View Thread·PermaLink | |
|
|
|
 |
|
 |
This code is OK if you only drag one item at a time. However if you're dragging more than one item and the drop point is below the selected items in the list, then the dragged items get their order reversed.
I would love to see a more robust implementation of this which correcly moves multiple items in the list. Any chance?
|
| Sign In·View Thread·PermaLink | 3.50/5 |
|
|
|
 |
|
 |
*Disclaimer* - this is my first post here.
I may have a way to fix this. Its not the most elegant or efficient, but there is definitely more than one way to solve the issue.
The 'ordering' problem when moving multiple selections down is due to the next item in the SelectedItems collection being inserted at the incorrect index - its going at the same one as the one previous, though its unintentional. Its happening because as each ListViewItem is 'moved', it is being cloned, the clone is inserted and then the old item is removed from the list.
I got around this in OnDragDrop by collecting the items to be removed in an ArrayList (like I said, there are better ways to do this) and then removing them all at once. This preserves the indices for insertion of groups.
I've tested it some, seems to be OK. I can't say how it will perform with any sort of load or extreme situation though.
Anyone else have a suggestion?
ArrayList itemsToRemove = new ArrayList(); for(int i=base.SelectedItems.Count; i>0;i--) { ListViewItem dragItem = base.SelectedItems[i-1]; int itemIndex = dragIndex; if(itemIndex==dragItem.Index) { return; } if(dragItem.Index { itemIndex++; } ListViewItem insertItem = (ListViewItem)dragItem.Clone(); base.Items.Insert(itemIndex, insertItem);
itemsToRemove.Add(dragItem); }
foreach (object item in itemsToRemove) { base.Items.Remove((ListViewItem)item); }
jay
|
| Sign In·View Thread·PermaLink | |
|
|
|
 |
|
 |
Jay,
thanks for your solution to the re-ordering problem within the ListView. I used a similar approach myself but as jet I haven't had an opportunity to update the article, however I'll make an extra effort and it should be available in the next few days.
David
|
| Sign In·View Thread·PermaLink | |
|
|
|
 |