Quantcast
Channel: Programming Forums
Viewing all articles
Browse latest Browse all 51036

Item focus listview c#

$
0
0
I have this piece of code in Listview-SelectedIndexChanged Event.
string get_gold = Regex.Replace(word, "[^0-9]+", string.Empty);
                if (gold >= Convert.ToInt32(get_gold))
                {
                        gold -= Convert.ToInt32(get_gold);
                }
                else
                {
                    MessageBox.Show("Error!");
                }

The problem is, when I click the item for the first time, it runs successfully. However, if I click the same item twice, it does nothing, it only does if I click in a different item.

The item is focused, but I can't get the focus out of him without giving me "errors" (because it duplicates the code).

Tried:
listview1.SelectedIndices.Clear(); 
listview1.SelectedItems.Clear();

Viewing all articles
Browse latest Browse all 51036

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>