By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
443,550 Members | 908 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 443,550 IT Pros & Developers. It's quick & easy.

Ghost Selection

P: 6
Hello,


In my application I have a Listview Control and I have written the code to move list items either up or down in the list. Also, the item being moved remains highlighted as it goes up or down. That part works fine,... almost. The only glitch in the system is that when I move the list item up, it leaves an outline of a selection on the last row of my list. It remains there regardless of which row is highlighted.

I do not know why it is there but I want to get rid of it without losing the functionality of my buttons that move a selected list item up or down on the list. Can anyone help me?


My up button code is as follows:

Expand|Select|Wrap|Line Numbers
  1.  
  2. 'Defines Variables
  3.         Dim strDepartment As String
  4.         strDepartment = txtDepartment.Text
  5.  
  6.         Dim strCatagory As String
  7.         strCatagory = txtCatagory.Text
  8.  
  9.  
  10.         'Determines Index
  11.         Dim Index As Integer
  12.         Index = ListView1.SelectedIndices(0)
  13.  
  14.         'Remove ListView Row
  15.         ListView1.Items.Remove(ListView1.SelectedItems(0))
  16.  
  17.         'Inserts Listview Row one level up
  18.         Dim objListItem As ListViewItem
  19.         objListItem = ListView1.Items.Insert(Index - 1, strDepartment)
  20.         objListItem.SubItems.Add(strCatagory)
  21.  
  22.  
  23.  
  24.         'Selects ListView row one UP
  25.         ListView1.Items(Index - 1).Selected = True
  26.         ListView1.Focus()
  27.         SendKeys.Send("{Down}")
  28.  
  29.  
Jan 4 '13 #1
Share this question for a faster answer!
Share on Google+

Post your reply

Sign in to post your reply or Sign up for a free account.