Hi,
I've created a listbox component which inherits from UltraListView (set with listbox properties).
In my class I've overrided many events such as ItemSelectionChanging, ItemCheckStateChanging etc.. in order to achieve my goals.
However I have a problem, and let's take this simple example: when a new Item is active, which means I've clicked on it, I change his color and modify its checkstate.
When my listbox gets focus and when I click on an item, the first Item of the list is processed too, because it seems to be active since the beginning my listbox has focus...After that there is no other problem of this kind, this just happens for the first selection!
Any idea to prevent the first Item of the listview from being Active ?
Or any idea of the problem if I'm wrong ?
The control automatically activates the first visible item when the control is entered, in emulation of Windows Explorer. You can prevent this by overriding OnEnter, setting a flag before the base implementation is called, and clearing it thereafter. Then, in OnItemActivating, if that flag is true, set the Cancel property of the event arguments to true.
Thank you for the trick, do you have any idea concerning the other question? With the property set to mark selected items ?
I wasn't able to understand that question; if by "mark" you mean to set the CheckState of each selected item, you can use the PerformAction method, with an actionCode of 'SetNextCheckStateForSelectedItems'.
In fact, when I select a new Item it becomes blue or white depending on its previous checked state (blue cyan for unchecked previous state and white for checked previous state). For this I've removed the default blue color of selection by applying a DrawFilter.
But when I've selected the item that was not selected before, it turns blue cyan, and I cannot turn it white because it is already selected. And the SelectionChanged event in which I've modified the color of my selection doesn't fire because the item is already selected .. Is there a way to add a property in which I can notify that the Item is selected and then be able to solve my problem?
How to implement it ?
And there was a post on this forum concerning this matter if I remeber well ... something dealing with a property named "Mark" or "Marked" added to the comboEditor but impossible to retrieve it!
Thanks !
Sorry, this forum is for the UltraListView control, and your original post led me tho believe that is the control to which you were referring. For both UltraListView and UltraComboEditor, when an item has a blue background, most developers refer to it as being "selected". There is no property named "Mark" or "Marked", for either control.
For the UltraListView control, you can determine whether an item is selected by checking for its presence in the control's SelectedItems collection. For UltraComboEditor, you determine whether an item is selected by comparing it to the control's SelectedItem property.
Hi thank you for your answer.
I was not referring to an already existing "Mark" property, I know there is no such property existing. I was referring to a property that you add to your control when you create a new control which inherits from UltraListView.
I did join you a text file in which you'll be able to see my Custom List Box.
If you have time you can bind it to whatever you want in your test program.
You'll see the way the component works when you will execute it.
The problem is when an item is already selected in blue cyan and if I select it again, it remains cyan although it should turn white. I know that it is because I've set 'cyan' as the selection default color ! I don't know how to get arround this problem. You'll see that the checkboxes are not necesarry too, but the ultralistview is the only way I've found to build this type of component.