Solved

Placing Icons in a ListView at a specific point.

Posted on 1998-12-06
4
161 Views
Last Modified: 2010-04-04
Hi,
I'm trying to put an Item into a TListView at certain coordinates X and Y given by a OnDragDrop event.
I'm using this piece of code for it :
procedure TForm1.ListView1DragDrop(Sender, Source: TObject; X, Y: Integer);
var ListItem: TListItem;
begin
  ListItem := ListView1.Items.Add;
  ListItem.Caption := TSpeedButton(Source).caption;
  ListItem.Top:=Y;
  ListItem.Left:=X;
End;
The problem now is that the caption alwas gets on top or on the left of my TListView. I'v tried to set IconsOptions.AutoArange to False or True, it won't matter..

Anyone that can help me ??

Thx

Pieter
0
Comment
Question by:plambrec
  • 2
4 Comments
 
LVL 4

Expert Comment

by:dwwang
ID: 1349570
I think set AutoArrange to false only takes effects when it is in LargeIcons, in other status of listview, the icon will be at top-left at anytime.
0
 
LVL 20

Expert Comment

by:Madshi
ID: 1349571
Yes, dwwang is right. But I think it should work in "vsIcon" and in "vsSmallIcon"...

Regards, Madshi.
0
 

Author Comment

by:plambrec
ID: 1349572
nope, sorry, i tried both icons and smallicons style (without an actual icon, just a caption). It won't work...
I've downloaded a component called ExtListView which is an extended listview. this might work....


0
 
LVL 4

Accepted Solution

by:
dwwang earned 100 total points
ID: 1349573
Hi, I think the solution is to use SetPosition, see Delphi's help below:

Positions the list item in its list view control.

procedure SetPosition(const Value: TPoint);

Description

Call SetPosition to move the list item to a specified position. The Value parameter specifies the desired coordinates of the upper-left corner of the list item.

Note:      The list view control must have its ViewStyle property set to either vsIcon or vsSmallIcon.

Regards,
Wang
0

Featured Post

Why You Should Analyze Threat Actor TTPs

After years of analyzing threat actor behavior, it’s become clear that at any given time there are specific tactics, techniques, and procedures (TTPs) that are particularly prevalent. By analyzing and understanding these TTPs, you can dramatically enhance your security program.

Join & Write a Comment

This article explains how to create forms/units independent of other forms/units object names in a delphi project. Have you ever created a form for user input in a Delphi project and then had the need to have that same form in a other Delphi proj…
Introduction The parallel port is a very commonly known port, it was widely used to connect a printer to the PC, if you look at the back of your computer, for those who don't have newer computers, there will be a port with 25 pins and a small print…
In this tutorial you'll learn about bandwidth monitoring with flows and packet sniffing with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're interested in additional methods for monitoring bandwidt…
When you create an app prototype with Adobe XD, you can insert system screens -- sharing or Control Center, for example -- with just a few clicks. This video shows you how. You can take the full course on Experts Exchange at http://bit.ly/XDcourse.

706 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

19 Experts available now in Live!

Get 1:1 Help Now