listbox

get value from DataTable

笑着哭i 提交于 2019-12-06 01:07:58
问题 I want to get all column value from DataTable and store it to the ListBox. Here is my code If myTableData.Rows.Count > 0 Then For i As Integer = 0 To myTableData.Rows.Count Dim DataType() As String = myTableData.Rows(i).Item(1) ListBox2.Items.AddRange(DataType) Next End If but when I compile that code, I got error message like this : Unable to cast object of type 'System.String' to type 'System.String[]' so, how to resolve this problem?? Please help me.... 回答1: You can try changing it to this

ASP.NET jQuery double listbox edit and save

风格不统一 提交于 2019-12-06 00:29:54
Okay - so I have been pulling out my hair on this one for far too long now. Hopefully you guys can help out. I have a form that allows a user to input/edit data about their company. Most of it is pretty straight-forward form field editing, but I have one part where I am allowing the user to select what state(s) their business operates in and then assign a contact to that state. I am using jQuery and 2 listBox controls where I allow the user to double-click the state(s) they want to operate in. The jQuery moves the selected state over to the other listBox as well as to a dropdown control where

WPF ListBox with CheckBox data template - Binding Content property of Checkbox not working

北战南征 提交于 2019-12-06 00:25:02
I am following Kelly Elias' excellent article on making a WPF checkListBox . However, in my case, I have to create my objects in code using reflection. The ListBox item source is populating appropriately and the data template is styling the ListBox correctly, resulting in a list of CheckBoxes, but no Content is being shown for the CheckBox. What am I doing wrong with the binding in my data template? For brevity here, see the link above for the CheckedListItem class; mine is unchanged. The Charge class, of which we will type CheckedListItem: public class Charge { public int ChargeId; public int

How to change ForeColor of SelectedItem in ListBox

寵の児 提交于 2019-12-06 00:20:37
I am facing a little issue in my project how can I change fore-color of text of selected items in ListBox . I can select all items of ListBox but I don't know how to change fore-color of text of selected items. This code am using in my project for select listbox items for (int i = 0; i < lbProductsToBuy.Items.Count; i++) { lbProductsToBuy.SetSelected(i,true); } printreceiptToken1(); dataGridView67.Rows.Clear(); Thanks. In these images you can see UI of my application. image1 and image2 . See this last image, I want to change this selected items fore-color. You can set DrawMode property of

rename an item in listbox

岁酱吖の 提交于 2019-12-05 23:58:16
I want to rename selected item in listbox. How to I can do this? Thanks. Edit: Revisiting this quite a few years later; below are the ways you can do this dependent on the UI framework you are using. This carries the assumption that you'd like to change the selected text. ASP.Net WebForms protected void ChangeListBoxSelectedItemText(string textToChangeTo) { lstBoxExample.SelectedItem.Text = textToChangeTo; } WPF - Assuming the ListBox contains Label objects // To achieve this in WPF you have to cast the object // This is because a ListBox can contain numerous types of UI objects var

Putting ListBox in ScrollViewer: mouse wheel does not work

扶醉桌前 提交于 2019-12-05 22:50:02
问题 My mouse wheel does not work when putting a ListBox in a ScrollViewer . Does the ListBox somehow "steal" this event? <ScrollViewer VerticalScrollBarVisibility="Auto" Style="{StaticResource myStyle}"> <ListBox> <ListBoxItem>Test 1</ListBoxItem> <ListBoxItem>Test 2</ListBoxItem> <ListBoxItem>Test 3</ListBoxItem> <ListBoxItem>Test 4</ListBoxItem> <ListBoxItem>Test 5</ListBoxItem> <ListBoxItem>Test 6</ListBoxItem> <ListBoxItem>Test 7</ListBoxItem> </ListBox> </ScrollViewer> Edit: as requested by

How to bind a ListBox to a DataTable from a session object?

家住魔仙堡 提交于 2019-12-05 21:46:40
I have a session object that contains a DataTable from my previous page, and i would like to bind this DataTable to a ListBox. I'v done this: protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { if (Session["bestStocks"] !=null) { DataTable dt = new DataTable(); dt = (DataTable)Session["bestStocks"]; DataView dv = new DataView(dt); BestStockslb.DataSource = dt; BestStockslb.DataBind(); } } } I get this result: Any suggestion? thanks, liron It seems you have forgot the DataTextField and DataValueField dt = (DataTable)Session["bestStocks"]; DataView dv = new DataView(dt);

How to create a single select list box that shows the selection using Razor

爱⌒轻易说出口 提交于 2019-12-05 21:19:15
How do I create a simple, single select list box using the Razor view engine? I'm currently running into two problems. The first is that the list box "Select" code generated has 'multiple' automatically added. Question One is how to turn that off. No, I don't want to have to use a drop down list box. Question Two is trickier. The generated "Select" in the output html does not show any items as being selected, despite the item in question have selected values. Here's my code: Object model: public class Description { public String code { get; set; } public SelectList codelist; } Controller: code

WPF ListBox using ItemsSource and ItemTemplate

戏子无情 提交于 2019-12-05 20:14:02
I'm confused as to how bindings are resolved when I have both an ItemsSource and an ItemTemplate in a WPF ListBox . I have an ObservableCollection<int> called ListOfIndexes . For each index, I want to look up its record in a database table. I hope to do that in the IndexToObjectDescriptionConverter . <ListBox ItemsSource="{Binding ListOfIndexes}" ItemTemplate="{Binding Converter={StaticResource IndexToObjectDescriptionConverter}}" /> But a breakpoint in the converter is telling me that the value being read in by the ItemTemplate binding is of the window itself — i.e., the DataContext of the

VBA realtime filter Listbox through Textbox

对着背影说爱祢 提交于 2019-12-05 20:05:24
I would like to filter a Listbox created from a list of values stored in a worksheet depending on text written in a textbox contained in the same userform. My Listbox has 4 or 5 columns (depending on OptionField selection) and I would like to search all the columns for the text written. Example: I write "aaa" in TextField and the Listbox should return a list based on all the lines whose column 1 or 2 or 3 or 4 or 5 contain "aaa". Below my code to refresh the list on OptionField selection (this code does not produce any error, it is just to show how I create my list): Sub RefreshList() Dim