c# - Listbox item stay focused after selection -
c# - Listbox item stay focused after selection -
i don't know if title express want. have listbox in wpf generate many elements. when click on element while still generating want selected item not move downwards list, cannot see anymore, want remain in exact position click on it.
if possible, can point ideas on how in c#?
thanks.
assuming thought , using winforms
step 1:
determine index of selected item in source.
step 2:
when adding items listbox
split listbox
@ index item insert item @ point, add together on remainder of items, while making sure you've removed item if elsewhere in list.
code:
//let's assume know how position of item when clicked , save //item variable called originalitem
public void puttheiteminthesamespot() { var listboxitems = (list<integer>)yourlistbox.datasource; var originalclikeditem = originalitem; var toppart = new list<integer>(); (i = 0; < itemposition; i++) { toppart.add(listboxitems[i]); } toppart.add(originalclickeditem); var bottompart = listboxitems.remove(toppart); yourlistbox.datasource = toppart.addrange(bottompart); }
saw edit beingness wpf
the should work in idea.
c# wpf
Comments
Post a Comment