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(So urceItem)
Call Items.Insert(0, SourceItem)
^Causes the item to be added to the end of the listview!
Thanks loads in advance.
Nick. 6 3399
ListView.Sortin g Property = SortOrder.None (default)?
"Nick" <no****@altaven te.com> schreef in bericht
news:ew******** *****@TK2MSFTNG P14.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(So urceItem) 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.Sortin g 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_SETITEMPOSI TION 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("use r32.dll", EntryPoint:="Se ndMessageA")> _
Public Shared Function sendMessage(ByV al iHandle As IntPtr, ByVal iMessage
As Integer, ByVal iWParam As Integer, ByVal iLParam As Long) As Integer
End Function
<DllImport("ker nel32.dll", EntryPoint:="Rt lMoveMemory")> _
Public Shared Sub MoveMemory(ByVa l 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(pInt RetVal, iValue, 2)
Return (pIntRetVal)
End Function
'~~~~~~~~~~~~~~
Call Win32Utility.se ndMessage(<list view handle>, LVW_SETITEMPOSI TION, <item
index>, MAKELONG(<desti nation 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.LargeIcon s', '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.LargeIcon s', 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****@altaven te.com> schreef in bericht
news:%2******** ********@TK2MSF TNGP14.phx.gbl. .. Hi there,
ListView.Sortin g 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_SETITEMPOSI TION 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("use r32.dll", EntryPoint:="Se ndMessageA")> _ Public Shared Function sendMessage(ByV al iHandle As IntPtr, ByVal iMessage As Integer, ByVal iWParam As Integer, ByVal iLParam As Long) As Integer End Function
<DllImport("ker nel32.dll", EntryPoint:="Rt lMoveMemory")> _ Public Shared Sub MoveMemory(ByVa l 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(pInt RetVal, iValue, 2) Return (pIntRetVal) End Function
'~~~~~~~~~~~~~~
Call Win32Utility.se ndMessage(<list view handle>, LVW_SETITEMPOSI TION, <item index>, MAKELONG(<desti nation 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.LargeIcon s', '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.LargeIcon s', 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****@altaven te.com> wrote in message
news:%2******** *******@TK2MSFT NGP09.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.LargeIcon s', '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.LargeIcon s', 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****@altaven te.com> wrote in message
news:%2******** ********@TK2MSF TNGP14.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****@altaven te.com> wrote in message news:%2******** *******@TK2MSFT NGP09.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.LargeIcon s', '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.LargeIcon s', 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();
listView1.Items.Add (myString);
}
Is there a way I can fill up the second column this easily? Thw way I'm currently doing it is using the subitems property to add it. Unfortunately,
|
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 ListView.Items.Add(), . I see
that it is a virtual method so it should be easy to do. If anyone can help I
would appreciate it greatly. I can do what I need to do in a different way
this would just make everything significantly cleaner and eaasier...
|
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 the overall
size of the listview.
My question therefore is, how can I tell if the items I have added
will fit in the listview at its given height?
A secondary one, just for interest sake...is there a way to determine
the exact heght needed...
|
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() & ".txt",
FileMode.OpenOrCreate)
|
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
because the ListView seems to be trying to "re-select" items that are no
longer there!
for example, giventhat I have 3 items in my list:
Select the first and remove it - no problem.
| |
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 New ListView
listView1.Bounds = New Rectangle(New Point(10, 10), New
Size(300, 200))
' Set the view to show details.
|
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 form every thing works fine: checking items by code
as well as checking with mouse:
Using the CheckdItems Property is confused too.
|
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 form every thing works fine: checking items by code
|
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 FillListViewFromFile(string path)
{
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look !
Part I. Meaning of...
|
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed.
This is as boiled down as I can make it.
Here is my compilation command:
g++-12 -std=c++20 -Wnarrowing bit_field.cpp
Here is the code in...
| |
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth.
The Art of Business Website Design
Your website is...
|
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules.
He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms.
Adolph will...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one.
At the time of converting from word file to html my equations which are in the word document file was convert into image.
Globals.ThisAddIn.Application.ActiveDocument.Select();...
|
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols.
I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
|
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
| |
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |