Quantcast
Channel: Windows Presentation Foundation (WPF) forum
Viewing all articles
Browse latest Browse all 18858

Avoid drag multi item to the same text box

$
0
0

Im using the following code to drag from list box to text box , when I have one text box and I use the following code it prevent to drag item to text box that already filled with Item

privatevoid listbox_SelectionChanged(object sender,SelectionChangedEventArgs e){if((e.AddedItems.Count==1)&&(string.IsNullOrEmpty(textbox1.Text)))

but when I add new text box (textbox2) and try to check if it already filled ,the check is failed for all of the text boxes ,how can I avoid that?

 
private void listbox_SelectionChanged(object sender, SelectionChangedEventArgs e)
        {
            if ((e.AddedItems.Count == 1) &&
                (string.IsNullOrEmpty(textbox1.Text) || string.IsNullOrEmpty(textbox2.Text)))
            {
                if (ListBox.SelectedItems.Count > 0)
                {
                    var mySelectedItem = ListBox.SelectedItem as User;
                    if (mySelectedItem != null)
                    {
                        DragDrop.DoDragDrop(ListBox, mySelectedItem.ToString(), DragDropEffects.Copy);
                    }
                }
            }
        }








Viewing all articles
Browse latest Browse all 18858

Trending Articles



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