Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 1889
  • Last Modified:

WPF Treeview - How do I prevent a treeview item from collapse when pressing the minus key on the key pad

Hi Experts,

I have a WPF  application with a Treeview.  What I want to know is how do I prevent a treeviewitem from collapsing when pressing the minus key on the key pad?

When the minus key is pressed on the main part of the keyboard, it works just fine, but the other minus key on the # pad collpases the currently selected treeviewitem.

Thanks,
Steve
0
OFGemini
Asked:
OFGemini
  • 2
1 Solution
 
OFGeminiAuthor Commented:
http://stackoverflow.com/questions/1177982/how-to-move-the-textbox-caret-to-the-right

        private void TextBox_PreviewKeyDown(object sender, KeyEventArgs e)
        {
            if (e.Key == Key.Subtract)
            {                                
                var tb = sender as TextBox;                
                int selStart = tb.SelectionStart;
                string before = tb.Text.Substring(0, selStart);
                string after = tb.Text.Substring(before.Length);
                tb.Text = string.Concat(before, "-", after);
                tb.SelectionStart = before.Length + 1;
                e.Handled = true;                
            }
        }
0
 
OFGeminiAuthor Commented:
the above link helped me...
0

Featured Post

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now