Hi there,
I'm trying to implement drag-drop for my listview control in large icon
view mode. Unfortunately the order of the items gets completely messed up
upon inserting the item back into the listview, removing the item obviously
keeps everything fine but the second I use insert the item is added to the
*end* of the listview. Does anyone have any tips on how I can solve this
issue??
Call Items.Remove(SourceItem)
Call Items.Insert(0,SourceItem)
^Causes the item to be added to the end of the listview!
Thanks loads in advance.
Nick. 6 3377
ListView.Sorting Property = SortOrder.None (default)?
"Nick" <no****@altavente.com> schreef in bericht
news:ew*************@TK2MSFTNGP14.phx.gbl... Hi there,
I'm trying to implement drag-drop for my listview control in large icon view mode. Unfortunately the order of the items gets completely messed up upon inserting the item back into the listview, removing the item obviously keeps everything fine but the second I use insert the item is added to the *end* of the listview. Does anyone have any tips on how I can solve this issue??
Call Items.Remove(SourceItem) Call Items.Insert(0,SourceItem) ^Causes the item to be added to the end of the listview!
Thanks loads in advance.
Nick.
Hi there, ListView.Sorting Property = SortOrder.None (default)?
I've tried that but it doesn't seem to have the desired effect, each of
my listview items text property is set to it's index, this occurs every time
an item is scrolled into view. I do not want any other text other than the
force index of the item to be displayed.
So when the listview attempts to sort the items I end up with the
obvious,
0, 1, 10, 100, 101, 102.... and so on and so fourth and such like.
I've just come across a method where you send the message
LVM_SETITEMPOSITION to the listview and the item should go to the position
that you desire, and as I have AutoArrange set to True it should then be
tidied up. But unfortunately I only seem to be able to get it to go to
index 0 or 1, probably due to some issue with my routines....
'~~~~~~~~~~~~~~
<DllImport("user32.dll", EntryPoint:="SendMessageA")> _
Public Shared Function sendMessage(ByVal iHandle As IntPtr, ByVal iMessage
As Integer, ByVal iWParam As Integer, ByVal iLParam As Long) As Integer
End Function
<DllImport("kernel32.dll", EntryPoint:="RtlMoveMemory")> _
Public Shared Sub MoveMemory(ByVal iDestination As Integer, ByVal iSource As
Object, ByVal iLength As Integer)
End Sub
'Macros
Public Shared Function MAKELONG(ByVal iLow As Integer, ByVal iHigh As
Integer) As Long
Return (LOWORD(iLow) Or (&H10000 * LOWORD(iHigh)))
End Function
Public Shared Function LOWORD(ByVal iValue As Long) As Integer
Dim pIntRetVal As Integer
Call MoveMemory(pIntRetVal, iValue, 2)
Return (pIntRetVal)
End Function
'~~~~~~~~~~~~~~
Call Win32Utility.sendMessage(<listview handle>, LVW_SETITEMPOSITION, <item
index>, MAKELONG(<destination X>, <destination Y>))
'~~~~~~~~~~~~~~
^ Presumably this would do as I'm hoping and move the position of the
item to whereever I desire, but it doesn't seem to be doing that, any ideas
on what I might be doing wrong??
Nick.
Lol, i don't know if the following will help you but:
When I create a listview in view mode 'View.Details', the 'Items.Insert'
works correctly. However,
when I create a listview in view mode 'View.LargeIcons', 'Items.Insert' does
not work and the listview sorts the items as it sees fit.
However ( again ), if you create a listview, set the view to 'View.Details',
insert items, add a button to your form that can switch the listview.view
mode to 'View.LargeIcons', then the items are not sorted.
So, whenever you insert new items, turn view mode to 'View.Details' and then
turn it back...hmmm.
"Nick" <no****@altavente.com> schreef in bericht
news:%2****************@TK2MSFTNGP14.phx.gbl... Hi there,
ListView.Sorting Property = SortOrder.None (default)?
I've tried that but it doesn't seem to have the desired effect, each of my listview items text property is set to it's index, this occurs every time an item is scrolled into view. I do not want any other text other than the force index of the item to be displayed.
So when the listview attempts to sort the items I end up with the obvious,
0, 1, 10, 100, 101, 102.... and so on and so fourth and such like.
I've just come across a method where you send the message LVM_SETITEMPOSITION to the listview and the item should go to the position that you desire, and as I have AutoArrange set to True it should then be tidied up. But unfortunately I only seem to be able to get it to go to index 0 or 1, probably due to some issue with my routines....
'~~~~~~~~~~~~~~
<DllImport("user32.dll", EntryPoint:="SendMessageA")> _ Public Shared Function sendMessage(ByVal iHandle As IntPtr, ByVal iMessage As Integer, ByVal iWParam As Integer, ByVal iLParam As Long) As Integer End Function
<DllImport("kernel32.dll", EntryPoint:="RtlMoveMemory")> _ Public Shared Sub MoveMemory(ByVal iDestination As Integer, ByVal iSource As Object, ByVal iLength As Integer) End Sub
'Macros Public Shared Function MAKELONG(ByVal iLow As Integer, ByVal iHigh As Integer) As Long Return (LOWORD(iLow) Or (&H10000 * LOWORD(iHigh))) End Function
Public Shared Function LOWORD(ByVal iValue As Long) As Integer Dim pIntRetVal As Integer Call MoveMemory(pIntRetVal, iValue, 2) Return (pIntRetVal) End Function
'~~~~~~~~~~~~~~
Call Win32Utility.sendMessage(<listview handle>, LVW_SETITEMPOSITION, <item index>, MAKELONG(<destination X>, <destination Y>))
'~~~~~~~~~~~~~~
^ Presumably this would do as I'm hoping and move the position of the item to whereever I desire, but it doesn't seem to be doing that, any ideas on what I might be doing wrong??
Nick.
Hi there, When I create a listview in view mode 'View.Details', the 'Items.Insert' works correctly. However, when I create a listview in view mode 'View.LargeIcons', 'Items.Insert' does not work and the listview sorts the items as it sees fit.
However ( again ), if you create a listview, set the view to 'View.Details', insert items, add a button to your form that can switch the listview.view mode to 'View.LargeIcons', then the items are not sorted.
So, whenever you insert new items, turn view mode to 'View.Details' and then turn it back...hmmm.
Well that just kind of confirms where I'm at, you can't get it to put
the items in the correct order automatically. Which is pretty lame really
considering the Index of the item is actually correct when it gets added to
the end, so how an item with index 0 can appear after an item of index 160 I
don't know!! It seems pretty silly.
I'm sure the answer lies in sending the correct message and as if by
magic the item should move, it's just getting the declarations etc. correct!
Nick.
Hi again,
Strangely if I use begin and end update the item stays in it's original
position with the new index number!!! Very weird!
Nick.
"Nick" <no****@altavente.com> wrote in message
news:%2***************@TK2MSFTNGP09.phx.gbl... Hi there,
When I create a listview in view mode 'View.Details', the 'Items.Insert' works correctly. However, when I create a listview in view mode 'View.LargeIcons', 'Items.Insert' does not work and the listview sorts the items as it sees fit.
However ( again ), if you create a listview, set the view to 'View.Details', insert items, add a button to your form that can switch the listview.view mode to 'View.LargeIcons', then the items are not sorted.
So, whenever you insert new items, turn view mode to 'View.Details' and then turn it back...hmmm.
Well that just kind of confirms where I'm at, you can't get it to put the items in the correct order automatically. Which is pretty lame really considering the Index of the item is actually correct when it gets added to the end, so how an item with index 0 can appear after an item of index 160 I don't know!! It seems pretty silly.
I'm sure the answer lies in sending the correct message and as if by magic the item should move, it's just getting the declarations etc. correct!
Nick.
Weyhey, I finally got the repositioning of the item to work, so in
combination with begin and end update I have a working solution. Thanks for
your help!
"Nick" <no****@altavente.com> wrote in message
news:%2****************@TK2MSFTNGP14.phx.gbl... Hi again,
Strangely if I use begin and end update the item stays in it's original position with the new index number!!! Very weird!
Nick.
"Nick" <no****@altavente.com> wrote in message news:%2***************@TK2MSFTNGP09.phx.gbl... Hi there,
When I create a listview in view mode 'View.Details', the 'Items.Insert' works correctly. However, when I create a listview in view mode 'View.LargeIcons', 'Items.Insert' does not work and the listview sorts the items as it sees fit.
However ( again ), if you create a listview, set the view to 'View.Details', insert items, add a button to your form that can switch the listview.view mode to 'View.LargeIcons', then the items are not sorted.
So, whenever you insert new items, turn view mode to 'View.Details' and then turn it back...hmmm.
Well that just kind of confirms where I'm at, you can't get it to put the items in the correct order automatically. Which is pretty lame really considering the Index of the item is actually correct when it gets added to the end, so how an item with index 0 can appear after an item of index 160 I don't know!! It seems pretty silly.
I'm sure the answer lies in sending the correct message and as if by magic the item should move, it's just getting the declarations etc. correct!
Nick.
This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: VM |
last post by:
How can I fill up a listview with text file contents?
My listview has two columns and the first column fills up with a while loop:
while (myString != null)
{
myString = sr.Readline();...
|
by: Dave Y |
last post by:
I am a newbie to C# and am having trouble trying to override a ListView
property method. I have created a new class derived from the Forms.Listview
and I cannot figure out the syntax to override...
|
by: J L |
last post by:
When I fill a listview, I resize the columns to fit the data. I need
to know if the data will fit vertically or if there will be a vertical
scroll bar. I need to know this so I can allow for it on...
|
by: gsb58 |
last post by:
Hi!
This saves data from column1 in a Listview to disk like: 2005-09-20.txt
I've come so far in my research:
Dim fs As New FileStream("C:\" &
MyCalendar.TodayDate.ToShortDateString() &...
|
by: Phill W. |
last post by:
(VB'2003)
What's the correct way to remove multiple, selected items from a
ListView control (say, from a ContextMenu)?
I ask because I'm getting a very annoying ArgumentOutOfRangeException...
|
by: samoore33 |
last post by:
I found this code on MSDN, and it works great. It creates a ListView
dynamically and add items to it and all. It is great. I have changed a
few of the column names to suit me.
Dim listView1 As...
|
by: Peter |
last post by:
Hi,
I have a problem with Listview using checkboxes.
If i check items by code BEFORE the form is shown the Listview.Items
are confused during the ItemChecked Event !!!
After showing the...
|
by: Peter |
last post by:
Hi,
I have a problem with Listview using checkboxes.
If i check items by code BEFORE the form is shown the Listview.Items
are confused during the ItemChecked Event !!!
After showing the...
|
by: =?Utf-8?B?UmF5IE1pdGNoZWxs?= |
last post by:
Hello,
In my application I need to periodically remove all current items from a
ListView and add a new set into it. The following abbreviated code contains
the basic idea:
private void...
|
by: Charles Arthur |
last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
|
by: emmanuelkatto |
last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud.
Please let me know.
Thanks!
Emmanuel
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
by: Sonnysonu |
last post by:
This is the data of csv file
1 2 3
1 2 3
1 2 3
1 2 3
2 3
2 3
3
the lengths should be different i have to store the data by column-wise with in the specific length.
suppose the i have to...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers,...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
|
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
| |