asp.net listbox problem
By : user1107220
Date : March 29 2020, 07:55 AM
This might help you foreach (Book b in o.list) { ListBox_Items.Items.Add(b.Title); } , Add AutoPostBack="True" in your aspx tag
|
ListBox problem in ASP.NET
By : user2202195
Date : March 29 2020, 07:55 AM
This might help you No jQuery involved, but all the swapping takes place on the client, any moved item will still be moved after a postback. code :
<select id="ListBox1" name="ListBox1" runat="server" size="5" >
<option>1</option>
<option>2</option>
<option>3</option>
<option>4</option>
<option>5</option>
</select>
<br />
<input class="button" onclick="moveSelectedItems(document.getElementById('ListBox1'), document.getElementById('ListBox2'));" type="button" value="<"/> <br/>
<input class="button" onclick="moveSelectedItems(document.getElementById('ListBox2'), document.getElementById('ListBox1'));" type="button" value=">"/><br/>
<select id="ListBox2" name="ListBox2" runat="server" size="5">
<option>a</option>
<option>b</option>
<option>c</option>
<option>d</option>
<option>e</option>
</select>
<asp:HiddenField runat="server" ID="ListOneHiddenField" />
<asp:HiddenField runat="server" ID="ListTwoHiddenField" />
<script type="text/javascript">
function moveSelectedItems(oListFrom, oListTo)
{
var oNewOption;
// Move the item from one list to another
oNewOption = document.createElement("OPTION");
oListTo.options.add(oNewOption);
oNewOption.innerText = oListFrom.options(oListFrom.selectedIndex).innerText;
oNewOption.value = oListFrom.options(oListFrom.selectedIndex).value;
oListFrom.options.remove(oListFrom.selectedIndex);
// Persist the pipe-separated set of items in each listbox to a hidden field
document.getElementById('ListOneHiddenField').value = "";
for (var j = 0; j < document.getElementById('ListBox1').options.length; j++)
document.getElementById('ListOneHiddenField').value += document.getElementById('ListBox1').options(j).value + "|";
document.getElementById('ListTwoHiddenField').value = "";
for (var j = 0; j < document.getElementById('ListBox2').options.length; j++)
document.getElementById('ListTwoHiddenField').value += document.getElementById('ListBox2').options(j).value + "|";
}
</script>
protected void Page_Load(object sender, EventArgs e)
{
string[] listItems;
if (IsPostBack)
{
// Clear the ListBox
ListBox1.Items.Clear();
// Split the set of items into an array
listItems = ListOneHiddenField.Value.Split("|".ToCharArray());
// Rebuild the set of list items
foreach (string listItem in listItems)
{
if (!string.IsNullOrEmpty(listItem))
{
ListBox1.Items.Add(new ListItem(listItem, listItem));
}
}
// Rinse and repeat
ListBox2.Items.Clear();
listItems = ListTwoHiddenField.Value.Split("|".ToCharArray());
foreach (string listItem in listItems)
{
if (!string.IsNullOrEmpty(listItem))
{
ListBox2.Items.Add(new ListItem(listItem, listItem));
}
}
}
}
|
WPF Listbox Selection problem
By : user3484907
Date : March 29 2020, 07:55 AM
I hope this helps . That is a known issue, as all those strings are the same the selection gets confused because they all are essentially the same object. If you create two identical strings in .NET it does not necessarily create a new one but may reuse the first instance, i am not an expert on this though. Either wrap the strings in a class (make them the Content of a ListBoxItem for example) or make sure the values are unique.
|
How to fix "bad listbox index" problem in Listbox.curselection() , tkinter ,Python?
By : Oliver Osted Nielsen
Date : March 29 2020, 07:55 AM
I wish this help you I'm trying to get the selection of a Listbox, as soon as someone select a selection. I'm using some codes like: , Just add exportselection=False to the listbox config. code :
audioListbox = tk.Listbox(window,exportselection=False)
|
Problem with C#, Listbox and GUI
By : user3820906
Date : March 29 2020, 07:55 AM
wish help you to fix your issue You need to put the long running operation on it's own thread. then report the progress back to the UI intermittently. You can see an example how to do this in another post of mine here.
|