Answer the question
In order to leave comments, you need to log in
Moving text from one ListBox to another ListBox with a double click, how to write it in ASP.NET code?
I made a reading from a file, also, I made buttons for moving text between ListBoxes, but I don’t know how to make it move by double-clicking, I didn’t find any sources on the Internet that would help. Please write code.
cs code if needed:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.IO;
using System.Security;
namespace SOVLAB_2_DOP
{
public partial class _Default : Page
{
protected void Page_Load(object sender, EventArgs e)
{
}
protected void Addl(object sender, EventArgs e)
{
StreamReader sr = new StreamReader(@"C:\Users\Ilya\source\repos\SOVLAB_2_DOP\1.txt");
stringline = string.Empty;
try
{
line = sr.ReadLine();
while (line != null)
{
this.ListBox1.Items.Add(line);
line = sr.ReadLine();
}
sr.Close();
}
finally
{
sr.Close();
}
}
protected void Vniz(object sender, EventArgs e) //down button
{
ListBox2.Items.Add(ListBox1.SelectedValue);
ListBox1.Items.Remove(ListBox1.SelectedValue);
}
protected void Verh(object sender, EventArgs e) //up button
{
ListBox1.Items.Add(ListBox2.SelectedValue);
ListBox2.Items.Remove(ListBox2.SelectedValue);
}
protected void ListBox1_SelectedIndexChanged(object sender, EventArgs e)
{
}
protected void ListBox2_SelectedIndexChanged(object sender, EventArgs e)
{
}
}
}
Answer the question
In order to leave comments, you need to log in
There is a MouseDoubleClick event, so you can do something like this:
FirstListBox.MouseDoubleClick += new RoutedEventHandler(FirstListBox_MouseDoubleClick);
private void FirstListBox_MouseDoubleClick(object sender, RoutedEventArgs e)
{
if (FirstListBox.SelectedItem != null)
{
.....
}
}
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question