Results 1 to 40 of 4199

Thread: CommonControls (Replacement of the MS common controls)

Threaded View

  1. #11
    Addicted Member
    Join Date
    Jul 2017
    Posts
    233

    Re: CommonControls (Replacement of the MS common controls)

    I will retry to make my point more clear by some questions :

    1 - What is the purpose of this explanation ?
    the purpose of this explanation is to make a comparison between two behaviors being discussed about the way we should follow when calling this line of code listview1.forecolor=.... .



    2 - what are the two ways being compared ?

    way1
    • Setting the listview forecolor should be applied to all items and sub items of a listview regardless of the specifically colored items . So , when we call listview1.forecolor=vbrgreen , we expect all items to be colored by green including specifically colored items

    way2
    • Setting the listview forecolor should be applied to all items and sub items of a listview except the specifically colored items . So , when we call listview1.forecolor=vbrgreen , we expect all items to colored by green excluding specifically colored items . And to reset any item to its original forecolor (green) , we should use listview1.listitem(i).forecolor = -1 to set item i color to be the main forecolor for the listview (green) .



    3 - why do I think that way2 is not the appropriate one (according to my opinion ) ?
    If I have a listview with forecolor green and has - say - 1000 items and I want to color some few items to be red (based on some condition) . I will run a loop through 1000 records and do comparison and set the item color to red if it met the condition and nothing wrong with that in both ways .

    The problem will rise up at this next point . When I intend to Re-run conditional formatting function , I should add a line of code before setting any specific items colors . This line should reset all items forecolors to its default using listview1.forecolor=listview1.forecolor and I expect all items to be colored to default as way1 suggests .
    On the other hand , using way2 , will force me to write another loop through 1000 items and perform this instruction listview1.listitem(i).forecolor = -1 to reset the 1000 items forecolor the listview main forecolor or add it to an existing loop which is not guaranteed in all of the cases and situations as loop may exist or not . Even if it existed , then we have added to it more 1000 * n instructions execution time through usercontrol classes , collections and properties and this will surely deteriorate its performance in large scale listviews.


    way1
    Code:
    Dim i as integer
    listview1.forecolor=listview1.forecolor
    for i=1 to 1000
    
    if number(i) > 7 then listview1.listitems(i).forecolor=vbred
    next i
    way2
    Code:
    Dim i as integer
    for i=1 to 1000
    
    listview1.listitems(i).forecolor= -1
    if number(i) > 7 then listview1.listitems(i).forecolor=vbred
    next i
    Also consider , in the previous code , I have made use of the already running loop to escape creating another loop to set colors to default . But in some cases not related to this example , this loop might not be available.


    4 - can items populating loop implicate or act as an already running loop to host item by item coloring ?

    yes , but in some cases , - like mine - which is also very common , this can not be done as the user calls a window where he can select the column and the condition for conditional formatting . So , this can not be done during items population phase . And also I dont want to repopulate the list view before running the conditional format function causing another loop to run before conditional formatting function loop to guarantee that all items colors are set to default .
    Note 1 : Items population after listview clearing method sets forecolors to the deafult

    5 - why did Microsoft provide a forecolor property for a lsitview ?
    to apply the color to all listview items .

    6 - why did Microsoft provide an item.forecolor property for a lsitview ?
    also to apply the color to all listview items ???!!!!! No . the one up there handles this mission . So , the answer is : they thought some users will need to color some specific items by some different color while keeping the general forecolor to handle all the items . So it is made for EXCEPTIONS . Seems logic to me .

    7 - what about the MS original list view which uses the same behavior ?
    At this moment , I feel like it is some type of bug or un-handled analysis which they did not take care of . Otherwise , there is a piece of information I dont know which made it necessary while setting the forecolor property to leave all specifically colored items as they are . I thought about one issue but I also dont find it a complete answer . I thought of they said : "Set the forecolor as you want by the general forecolor . Now for exceptions use item.forecolor and don`t worry when you reset the general forecolor again we will not touch your exceptions to not oblige you to re-run the code for coloring exceptions again (saving performnce) and if you want to reset your exceptions to default use the value -1 to the item.forecolor using likely a loop (no performance saving here) " . But this has many more questions to be asked about the way they implemented it . Could it has been done more easier and logical and also performance-considerations aware ? . why dont I pass -1 to the general forecolor ? why to keep my exceptions while mainly in the level of items re-populating it erases all settings (this happens more often than just passing a forecolor to the listview) so I will anyway populate the items (now all colors removed see note 1 above) and I will color my exceptions again each time I refresh my data .

    To simplify : Which one of these scenarios occur more often than the other ?

    1- setting the general forecolor at runtime for a listview . (there where Microsoft wants to keep specific forecolors)
    2- refreshing list items and repopulating the list view . (which will remove all specific forecolors)

    surely the second case with a ratio about 300 :1

    What is the worth of protecting exceptions while they will be demolished 300 times before it is even needed to be protected . Not only this is not useful , but also this protection operation will cost more performance load to recover from.

    I mean , the general forecolor setting occurrance which will happen 1 time to 300 times repopulating which will demolish your protection to the (1 occurrance ) which also cost you over performance load . Why did not they even design this protection in a better way to recover from ? if I even consider this protection was necessary . They saved your effort in one time and you will exert it 300 times each time you repopulate the items .

    So , It is an open discussion for everybody who can provide us with a case where he could not do without this feature or cases supporting my point . Maybe we can change the mind about going original MS road . If it was badly designed , can we improve this issue ?

    This is not a personal demand , even about this performance issue , it will not exhaust my apps which dont usually load more then 30 to 60 thousands records where such loops will not heavily affect performance . I opened the discussion just to improve it IF AND ONLY IF we agree to the point I have declared above . And of course you are free to decide krool .

    Maybe I am missing something which makes my post totally wrong , but I will be glad to learn if so . I created my opinion based on that I did not find any reason for keeping these exceptions not affected by the general forecolor and the negative effect on performance while trying to recover from this protection .

    @chosk @Cube8 . Firstly thanks for trying to help by code but it was not the problem for me . I was talking about performance . Thanks again

    Hi Krool,

    I hope you keep to the original MS behaviour. Because I have preference setting for users to change forecolor and row backcolor, while keeping those cells already colored unchanged. Example, for alternate row backcolors of white and green the forecolor usually black. For alternate row backcolors of gray and black the forecolor usually white. Those cells already colored before the change maintain their cell colors. If you change away from original MS behaviour, not only will I be screwed but others also using your controls who are coding according to MS behaviour.
    This is not an issue to be affected by any of the two methods chosk . It is a visual matter which can be solved by assigning the appropriate colors to each theme .
    Last edited by Hosam AL Dein; Sep 12th, 2017 at 05:46 AM.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width