Search the Community
Showing results for tags 'listview'.
Found 7 results
-
Specs: Delphi XE7, VCL, windows 7, Dell laptop (i3 core, 2.40GHz) I have been playing around with the Listview control, (via ViewStyle=vsReport) learning how to add items at runtime through code (not using a database/binder), for 100 to a few thousand items. Again, just playing around with throwing together a quick listview of data, and seeing if there is use for it versus going the database dataset route. Note, because I was self-learning about listview from scratch, I did have a lot of trouble figuring out how to populate the listview. And now that I know how to, I am also sharing it here for reference for others struggling to do the same. Below, is the code snippet of how I created the initial fields and then populate them. The ViewStyle should be set to vsReport in the properties section in order to show a table column layout at run time. It works and that's all that matters at this point in this indeviour. procedure TForm1.btnAddClick(Sender: TObject); var itm : TListItem; Col : TListColumn; s : string; et : int64; SW : TStopwatch; begin Col := lv1.Columns.Add; Col.Caption := 'LN'; Col.Alignment := taLeftJustify; Col.Width := 30; Col := lv1.Columns.Add; Col.Caption := 'ItemNo'; Col.Alignment := taLeftJustify; Col.Width := 60; Col := lv1.Columns.Add; Col.Caption := 'Desc'; Col.Alignment := taLeftJustify; Col.Width := 160; setlength(ary,10); // create the array length (1,2,3,4,5,6,7,8,9,0) chars beep; SW := TSTopWatch.StartNew; // start timing it lv1.Items.BeginUpdate; for i := 0 to 25000 do begin // ary := genRandValues; // generate random numbers ie (2,9,8,4,7,5,6,0,1,3) s:=listtostr(ary); // convert array list into a string var ie ('2984756013') itm:=lv1.Items.Add; // create a row itm.Caption := i.ToString(); // add the major field, ie 'LN', thus the populate with variable i as line numbers itm.SubItems.Add(''); itm.SubItems[0]:= s; // itemno ie '2984756013', and so on. itm.SubItems.Add(''); itm.SubItems[1]:= s; // desc ie same, ... end; lv1.Items.EndUpdate; SW.Stop; // finish timing eb1.text:=(intToStr(SW.ElapsedTicks)+' ticks / '+intToStr(SW.ElapsedMilliseconds)+' ms'); beep; end; But the problem I am having is that even when using the .BeginUpdate/.EndUpdate the speed is still a bit slow. For example, to fill a listview with 10,000 elements, it costs me about aprox 1.6 seconds run time, or for 25,000 elements, 7.6 seconds. I had a look at the earlier part of the for/loop, where I am generating the random numbers and then converting them to strings. I REM'ed them out and the time was still the same or ever-so-slightly less, maybe 1.5 seconds for instance. So that does not seem to be a major issue in slowing the listview down. Is this the maximum throughput I can expect from listview? or Is there anything else I can do to speed this up a lot more?
- 17 replies
-
- delphi xe7
- listview
-
(and 1 more)
Tagged with:
-
delphi Virtual Listview does not work because 'un-select' is not reported
Bart Kindt posted a topic in Windows API
I have a unit which tries to use the TListView in Virtual mode, by setting OwnerData to true. Theroretically all this should simply work, as long as I monitor the OnData, OnSelectItem, OnDataStateChange and possibly OnChange. But what happens, it that all 'OnSelect's are reported by Windows, but NOT all 'unSelect's. As a result, my VirtualItemList end up with more and more Selected Items, while in reality, there is (for example) only 1 Selected Item in the ListView. Below is an (Log) example of what happens: = I click on item 0: OnSelectItem: Item not assigned! OnChange: Index=0 Virtual Count=3001 Item=Caption 0 Selected=TRUE OnSelectItem: Item=Caption 0 Item.Selected=TRUE Selected=TRUE = I now shift-click on Item3, to multi-select all 4 Items: VirtualItemList.OnSelectItem: Item not assigned! *** OnDataStateChange: Start=0 End=3 *** OnDataStateChange: 0 Item: Caption 0 Selected=TRUE *** OnDataStateChange: 1 Item: Caption 1 Selected=TRUE *** OnDataStateChange: Changing VirtualItem Caption 1 to TRUE *** OnDataStateChange: 2 Item: Caption 2 Selected=TRUE *** OnDataStateChange: Changing VirtualItem Caption 2 to TRUE *** OnDataStateChange: 3 Item: Caption 3 Selected=TRUE *** OnDataStateChange: Changing VirtualItem Caption 3 to TRUE OnChange: Index=0 Virtual Count=3001 Item=Caption 0 Selected=TRUE OnChange: Index=3 Virtual Count=3001 Item=Caption 3 Selected=TRUE MouseUp: Base Selcount=4 Virtual=4 REAL=4 NOTE: - OnSelectItem is NOT called during 'Shift-Click' for the Selected items. - I now must use OnDataStateChange to Select these. - OnChange is ONLY called for Index 0 and 3. Not for the ones in between. = I now click on Item 4. (This should UN-select all other Items. It does do so on the screen...) OnSelectItem: Item not assigned! OnChange: Index=3 Virtual Count=3001 Item=Caption 3 Selected=FALSE *** OnChange: Caption 3 has changed to: FALSE OnChange: Index=4 Virtual Count=3001 Item=Caption 4 Selected=TRUE *** OnChange: Caption 4 has changed to: TRUE OnSelectItem: Item=Caption 4 Item.Selected=TRUE Selected=TRUE MouseUp: Base Selcount=1 Virtual=1 REAL=4 NOTE: - The OnChange only reported UNSelect for Item 3, and the Select for Item 4, but there is no event anywhere for Item 0, 1 and 3. - I now have FOUR Selected items in my Virtual List (The SelCount is hard overwritten from the ListView Selcount) - OnDataStateChange is NEVER called to report all the UN-Selects. The entire Test program source code can be downloaded here (200k): https://sartrack.nz/temp/VirtualListViewTest.zip I really wonder if it possible at all to do this, as this seems to be a Windows issue. Using Windows 10, Delphi 11. -
Hi, how can I write a respond to the event, that user has changed the width of a column in a TListView (report view) by dragging a column border with a mouse?
-
Hi, I found a way to sort my lists using Sort an OnCompare event but I don't figure out a functional way to use Sort(Compare) method (Rio 10.3.3) Any clues ? Thanks
-
Hello members! I started learning delphi few months ago and recently i discovered that we can make really beautiful user interfaces with delphi FMX styles. I saw on the internet this animation demo ( This is just a design ) and I wanted to implement it in delphi: https://thumbs.gfycat.com/ShamelessConfusedAmbushbug-mobile.mp4 I was thinking to use ListView component in FMX for this with ItemApperance -> DynamicApperance. Everything was cool but i faced one problem. Problem is that I am not sure that TlistViewItem can perform animation when it is been added to the ListView. From my understandings i can only animate "Text1" and other items if i add them -> https://i.imgur.com/Y3SWIsT.jpg There is no option ( or I dont know how to find it ) To animate whole TListItemView when is added to a ListView. **WORKAROUND THAT I HAVE ON MY MIND** I was thinking to drop a ListBox and to add on it "TListBoxItem", after that i would right click it and Go on edit custom style, and try to make it look as i want. I tested this tutorial for editing the look of "TListBoxItem" and it is working nicely: https://www.experts-exchange.com/articles/10054/Implementing-a-ListView-in-Firemonkey.html For animation i planned to use this resources ( not tested, i dont know if it will work ) : So what is my question actually, well i would like to achieve similar design and effect from gif that i showed to you. I would like to use ListView with DynamicApperance. I would like to someone confirm me if that is possible and to give me some references or resource material where i could read more about it.. Also if there is someone who would like to give me a code example i would appreciate a lot. From my tests that i performed ( loop 1000 times, and add 1000 items on ListView and ListBox ) I can say that ListBox performed a lot slower so I would prefer ListView for this, also i think that using ListView here is better practice since ListView is more suitable for this situation based on this post: http://www.delphigroups.info/2/8f/544471.html At the end I just want to point out that im using FMX ONLY because i found it easier to make styles, this program is for Windows only platform. I am using Delphi Rio community ( Free version ). I would also like to add that option " Pull to refresh " that you see on that gif is not needed. Thank you for your answers and help! 🙂
- 4 replies
-
- delphi rio
- fmx
-
(and 5 more)
Tagged with:
-
I have a listview on a form that is sizable. i hard coded 5 columns to it but when different users with different monitors, laptops the columns overlap the text. is there a way to detect when text overlaps and then i could reduce the number of columns and refresh the listview. the text that is displayed is file names but depending on the users that info could be longer than the others. i would rather not hard code the # of columns but i don't know when to trigger the increase/decrease the number of columns.
- 2 replies
-
- listview
- multple columns
-
(and 1 more)
Tagged with:
-
I have a listview application with dynamic items, which is connected to a fdmemtable, when clicking repeatedly on any item in the listview, the application closes. If you put the listview without the dynamic items, and clicking several times this does not occur I'm using delphi 10.2.3 works ok, but in delphi 10.3 comunity, the error occurs, with android 8.0.1 Has anyone had this problem ?
- 3 replies
-
- firemonkey
- listview
-
(and 1 more)
Tagged with: