Search Results

Search found 919 results on 37 pages for 'listbox'.

Page 6/37 | < Previous Page | 2 3 4 5 6 7 8 9 10 11 12 13  | Next Page >

  • Binding Listbox item source to a collection of collections in windows phone 7

    - by Tee
    Hi there, I am trying to bind a Listbox ItemSource to a collection of multiple Lists. i.e. List PersonCollection List Person List Collection Now I need to show items from both of these list. In wpf you could use HierarchicalDataTemplate i believe, but not sure how I can do it in windows phone 7. Tried with Blend and it generates the following data template. <DataTemplate x:Key="PersonDataTemplate"> <Grid> <StackPanel Margin="0,0,1,0" Orientation="Vertical" VerticalAlignment="Top"> <TextBlock Margin="0,0,1,0" TextWrapping="Wrap" Text="{Binding Person[0].Name}" d:LayoutOverrides="Width"/> <TextBlock Margin="0,0,1,0" TextWrapping="Wrap" Text="{Binding Collection[0].Total}" d:LayoutOverrides="Width"/> </StackPanel> </Grid> </DataTemplate> Is there another way I can do this? I have tried to set the DataContext of Textbox in DataTemplate to individual arrays but did not seem to work. Cant find anything similar on the net apart from the confirmation that HierarchicalDataTemplate is not supported in Windows Phone 7. I have other ways to do but none elegant.. Thanks in advance. Regards

    Read the article

  • Assigning values to the lable through database depending on listbox values

    - by SurajVitekar
    I want to assign the values of five labels from database regarding to values selected in listbox. The db query returns single column with multiple records. Please help. I'm working with C# 2010 and MS SQL. My current code is: private void listBox1_SelectedIndexChanged(object sender, EventArgs e) { try { String c1, c2; c1 = "NULL"; MessageBox.Show("LB index :"+listBox1.SelectedIndex.ToString()); //p = listBox1.SelectedItem.ToString(); SqlConnection con = new SqlConnection(); con.ConnectionString = "Data Source=localhost;Initial Catalog=eVoting;Integrated Security=True;Pooling=False"; con.Open(); MessageBox.Show("List bOx sect :"+listBox1.SelectedValue.ToString()); SqlCommand cmd = new SqlCommand("select Firstname from candidates where position ='" + listBox1.SelectedValue.ToString() + "'", con); int index = 0; SqlDataReader reader = cmd.ExecuteReader(); while(reader.Read()) { if (index == 0) { c1 = reader[index].ToString(); radioButton1.Text = c1; } if (index == 1) { c1 = reader[index].ToString(); radioButton2.Text = c1; } if (index == 2) { c1 = reader[index].ToString(); radioButton3.Text = c1; } if (index == 3) { c1 = reader[index].ToString(); radioButton4.Text = c1; } if (index == 4) { c1 = reader[index].ToString(); radioButton4.Text = c1; } if (index == 5) { c1 = reader[index].ToString(); radioButton5.Text = c1; } MessageBox.Show("c1 :" + c1); index++; } } catch (Exception E) { } }

    Read the article

  • Binding Contents of a ListBox to Selected Item from Another Listbox w/JSF & Managed Beans

    - by nieltown
    Hi there! I currently have a JSF application that uses two listboxes. The first, say ListBox1, contains a list of manufacturers; each option comes from the database (via a method getManufacturers in a class called QueryUtil), is populated dynamically, and its value is an integer ID. This part works so far. My goal is to populate a second listbox, say ListBox2, with a list of products sold by the manufacturer. This list of products will come from the database as well (products are linked to a manufacturer via a foreign key relationship, via a method getProducts in my QueryUtil class). How do I go about doing this? Please bear in mind that I've been working with JSF for under 24 hours; I'm willing to accept the fact that I'm missing something very rudimentary. Again, I've been able to populate the list of manufacturers just fine; unfortunately, adding the Products component gives me java.lang.IllegalArgumentException: argument type mismatch faces-config.xml <managed-bean> <managed-bean-name>ProductsBean</managed-bean-name> <managed-bean-class>com.nieltown.ProductsBean</managed-bean-class> <managed-bean-scope>request</managed-bean-scope> <managed-property> <property-name>manufacturers</property-name> <property-class>java.util.ArrayList</property-class> <value>#{manufacturers}</value> </managed-property> <managed-property> <property-name>selectedManufacturer</property-name> <property-class>java.lang.Integer</property-name> <value>#{selectedManufacturer}</value> </managed-property> <managed-property> <property-name>products</property-name> <property-class>java.util.ArrayList</property-class> <value>#{products}</value> </managed-property> <managed-property> <property-name>selectedProduct</property-name> <property-class>java.lang.Integer</property-name> <value>#{selectedProducts}</value> <managed-property> </managed-bean> com.nieltown.ProductsBean public class ProductsBean { private List<SelectItem> manufacturers; private List<SelectItem> products; private Integer selectedManufacturer; private Integer selectedProduct; public ProductsBean() {} public Integer getSelectedManufacturer(){ return selectedManufacturer; } public void setSelectedManufacturer(Integer m){ selectedManufacturer = m; } public Integer getSelectedProduct(){ return selectedProduct; } public void setSelectedProduct(Integer p){ selectedProduct = p; } public List<SelectItem> getManufacturers(){ if(manufacturers == null){ SelectItem option; plans = new ArrayList<SelectItem>(); QueryUtil qu = new QueryUtil(); Map<Integer, String> manufacturersMap = qu.getManufacturers(); for(Map.Entry<Integer, String> entry : manufacturersMap.entrySet()){ option = new SelectItem(entry.getKey(),entry.getValue()); manufacturers.add(option); } } return manufacturers; } public void setManufacturers(List<SelectItem> l){ manufacturers = l; } public List<SelectItem> getProducts(){ if(products == null){ SelectItem option; products = new ArrayList<SelectItem>(); if(selectedPlan != null){ PMTQueryUtil pqu = new PMTQueryUtil(); Map<Integer, String> productsMap = pqu.getProducts(); for(Map.Entry<Integer, String> entry : productsMap.entrySet()){ option = new SelectItem(entry.getKey(),entry.getValue()); products.add(option); } } } return products; } public void setProducts(List<SelectItem> l){ products = l; } } JSP fragment <h:selectOneListbox id="manufacturerList" value="#{ProductsBean.selectedManufacturer}" size="10"> <f:selectItems value="#{ProductsBean.manufacturers}" /> </h:selectOneListbox> <h:selectOneListbox id="productList" value="#{PendingPlansBean.selectedProduct}" size="10"> <f:selectItems binding="#{ProductsBean.products}" /> </h:selectOneListbox>

    Read the article

  • C# - Kinetic scrolling with ListBox or ListView?

    - by fonix232
    I am doing a simple application for touch screen devices, and I would like to implement today's fashion: kinetic scrolling. Is it possible to do, and if yes, how? PS: Kinetic scrolling: A scrolling mechanism where you don't use a scrollbar to scroll the content, but you touch the list itself, and pull and push it. The "physics engine" then counts out the speed, and stops based on the given settings.

    Read the article

  • cant get my listbox to display objects

    - by Silvia Stoyanova
    Hello everyone I've been trying to put some objects in an ASP.NET list box but its just not working. I do have an overriden ToString method so I cant understand why this statement wont work. Here's the code that I use: for (int i = 0; i < fitnessClassList.Count(); i++) { lbDisplayItems.Items.Add(fitnessClassList.getFitnessClass(i)); } And the errors that I get: Error 2 Argument 1: cannot convert from 'FitnessClassManager.FitnessClassOpportunity' to 'System.Web.UI.WebControls.ListItem' Error 1 The best overloaded method match for 'System.Web.UI.WebControls.ListItemCollection.Add(System.Web.UI.WebControls.ListItem)' has some invalid arguments

    Read the article

  • Automatically number items in a wpf listbox

    - by evan
    I have a person class with two properties, Name an Age. I know how to use databinding to display a collection of person in a wpf list box and how to modify the listitemtemplate to customize how each person is displayed. Now I'd like to number each person on the list according to the order they appear on the list (which could change as the the items were sorted via name or age in the display). Is there a way to do that with the item template so instead of having a list like Rob - 14 John - 56 Suzy - 32 it would be 1) Rob - 14 2) John - 56 3) Suzy - 32 Basically i'd like to do something like: <ListView.ItemTemplate> <DataTemplate> <WrapPanel> **<TextBlock Text="{Binding CurrentPositionInList}" />** <TextBlock Text="{Binding Path=Name}" /> <TextBlock Text="{Binding Path=Age}" /> </WrapPanel> </DataTemplate> Thanks in advance!

    Read the article

  • Expanders inside listbox leaving blank space on collapse

    - by siz
    We have a rather complex UI that is presenting some problems for us. I have a ListBox that contains a set of DataItems. The DataTemplate for each item is an Expander. The header is text, the content of the Expander is a ListBox. The ListBox contains SubDataItems. The DataTemplate for each SubDataItem is an Expander. Here is a simplified XAML in which I reproduce the issue: <ListBox ItemsSource="{Binding Items}"> <ListBox.ItemTemplate> <DataTemplate> <Expander Header="{Binding Header}"> <ListBox ItemsSource="{Binding SubItems}"> <ListBox.ItemTemplate> <DataTemplate> <Expander Header="{Binding SubHeader}"> <Grid Height="40"> <TextBlock Text="{Binding SubText}" /> </Grid> </Expander> </DataTemplate> </ListBox.ItemTemplate> </ListBox> </Expander> </DataTemplate> </ListBox.ItemTemplate> </ListBox> There is a problem with how the layout is produced. If any Expander corresponding to the SubDataItem is expanded, the ListBoxItem containing this ListBox (the Expander.Content in the parent DataTemplate) correctly requests more space. So I can expand all SubDataItems and correctly see my data. However, when I collapse, the space I previously asked to expand, remains blank, instead of being reclaimed by the ListBoxItem. This is a problem because if I have say 10 SubDataItems and happen to expand all of them at the same time and then collapse, there is a significant amount of white space wasting my real estate. How can I force WPF to resize the ListBoxItem to the correct state?

    Read the article

  • How to change which item is “outlined” in a ListBox without changing the selection?

    - by Timwi
    How do you change which item is “outlined” in a ListBox? See the following screenshot for clarification: Background: I want to have a standard multi-select listbox that works normally. Unfortunately, the Windows Forms ListBox (with SelectionMode.MultiExtended) is not fully functional. The missing functionality is that it doesn’t let you select a disjoint set of items by using Ctrl+Arrow keys and Ctrl+Space. (Try it in Windows Explorer to see how it’s supposed to work.) I am trying to subclass ListBox and add this missing functionality. To this end, I intend to respond to Ctrl+Arrow keys in the OnKeyDown protected method, but in order to do so, I need to be able to move the outline without changing the set of selected items. How do I do that?

    Read the article

  • How can I set different Tooltip text for each item in a listbox?

    - by Michael Lang
    I have a listbox that is databound to a Collection of objects. The listbox is configured to display an identifier property of each object. I would like to show a tooltip with information specific to the item within the listbox that is being hovered over rather than one tooltip for the listbox as a whole. I am working within WinForms and thanks to some helpful blog posts put together a pretty nice solution, which I wanted to share. I'd be interested in seeing if there's any other elegant solutions to this problem, or how this may be done in WPF.

    Read the article

  • Why am I needing to click twice on a WPF listbox item in order to fire a command?

    - by Donal
    Hi, I'm trying to make a standard WPF listbox be dynamically filled, and for each item in the list box to launch a command when clicked. Currently I have a working listbox, which can be filled and each item will fire the correct command, but in order to fire the command I have to click the list item twice. i.e, Click once to select the item, then click on the actual text to fire the command. As the list is dynamically created, I had to create a data template for the list items: <ListBox.ItemTemplate> <DataTemplate> <TextBlock Margin="4,2,4,2"> <Hyperlink TextDecorations="None" Command="MyCommands:CommandsRegistry.OpenPanel"> <TextBlock Text="{Binding}" Margin="4,2,4,2"/> </Hyperlink> </TextBlock> </DataTemplate> </ListBox.ItemTemplate> Basically, how do I remove the need to click twice? I have tried to use event triggers to fire the click event on the hyperlink element when the list box item is selected, but I can't get it to work. Or, is there a better approach to dynamically fill a listbox and attach commands to each list item? Thanks

    Read the article

  • Visual Basic 2010 Listbox Error [migrated]

    - by stargaze07
    what is the meaning of this error? sorry it's my first time to use Visual basic 2010, I'm not familiar with this kind of error, I use this for selecting all the files in the listbox and tried to move or copy to another listbox in other form. Error 1 'ToArray' is not a member of 'System.Windows.Forms.ListBox.ObjectCollection'. This is the code I use. Private Sub Button1_Click_1(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click If RadioButton1.Checked Then Dim itemsToMove = ListBox1.Items.ToArray() For Each item In itemsToMove Form2.lstP.Items.Add(item) ListBox1.Items.Remove(item) Next Form2.Show() End If End Sub Can someone help me with this?

    Read the article

  • Why is ListBoxFor not selecting items, but ListBox is?

    - by Roger Rogers
    I have the following code in my view: <%= Html.ListBoxFor(c => c.Project.Categories, new MultiSelectList(Model.Categories, "Id", "Name", new List<int> { 1, 2 }))%> <%= Html.ListBox("MultiSelectList", new MultiSelectList(Model.Categories, "Id", "Name", new List<int> { 1, 2 }))%> The only difference is that the first helper is strongly typed (ListBoxFor), and it fails to show the selected items (1,2), even though the items appear in the list, etc. The simpler ListBox is working as expected. I'm obviously missing something here. I can use the second approach, but this is really bugging me and I'd like to figure it out. For reference, my model is: public class ProjectEditModel { public Project Project { get; set; } public IEnumerable<Project> Projects { get; set; } public IEnumerable<Client> Clients { get; set; } public IEnumerable<Category> Categories { get; set; } public IEnumerable<Tag> Tags { get; set; } public ProjectSlide SelectedSlide { get; set; } } Update I just changed the ListBox name to Project.Categories (matching my model) and it now FAILS to select the item. <%= Html.ListBox("Project.Categories", new MultiSelectList(Model.Categories, "Id", "Name", new List<int> { 1, 2 }))%> I'm obviously not understanding the magic that is happening here. Update 2 Ok, this is purely naming, for example, this works... <%= Html.ListBox("Project_Tags", new MultiSelectList(Model.Tags, "Id", "Name", Model.Project.Tags.Select(t => t.Id)))%> ...because the field name is Project_Tags, not Project.Tags, in fact, anything other than Tags or Project.Tags will work. I don't get why this would cause a problem (other than that it matches the entity name), and I'm not good enough at this to be able to dig in and find out.

    Read the article

  • How do I get all values from a listbox that are not selected in ASP.NET MVC

    - by Nick Reeve
    Hello, I have a form that (amongst other things) contains 2 multi-select listboxes. Basically you can add items to the one on the right from the full list of items on the left using some add/remove buttons. The problem is that I cannot see a way of picking up the contents of the listbox when posting back to the controller. I have followed this example: http://ittecture.wordpress.com/2009/04/30/tip-of-the-day-198-asp-net-mvc-listbox-controls/ This works fine if you have actually selected the items in the listbox before posting. That's not really the way I think this UI should behave though. Hope that makes sense, Nick

    Read the article

  • How to highlight matching sub-strings inside a ListBox?

    - by Kishore Kumar
    I have one TextBox and one listbox for searching a collection of data. While searching a text inside a Listbox if that matching string is found anywhere in the list it should show in Green color with Bold. eg. I have string collection like "Dependency Property, Custom Property, Normal Property". If I type in the Search Text box "prop" all the Three with "prop" (only the word Prop) should be in Bold and its color should be in green. Any idea how it can be done?. Data inside listbox is represented using DataTemplate.

    Read the article

  • WPF - ListBox ignores Style When ItemsSource is bound

    - by Andy T
    Hi, I have created styled a ListBox in WPF so that it is rendered as a checkbox list. When I populate the ListBox's items manually, the styling works perfectly. However, when I instead bind the ItemsSource of the ListBox to a static resource (an ItemsControl containing the required items), the styling is completely dropped. Here's the style: <Style x:Key="CheckBoxListStyle" TargetType="ListBox"> <Style.Resources> <Style TargetType="ListBoxItem"> <Setter Property="Template"> <Setter.Value> <ControlTemplate TargetType="ListBoxItem"> <Grid Margin="2"> <Grid.ColumnDefinitions> <ColumnDefinition Width="Auto" /> <ColumnDefinition /> </Grid.ColumnDefinitions> <CheckBox IsChecked="{Binding IsSelected, RelativeSource={RelativeSource TemplatedParent}, Mode=TwoWay}"/> <ContentPresenter Grid.Column="1" Margin="2,0,0,0" /> </Grid> </ControlTemplate> </Setter.Value> </Setter> </Style> </Style.Resources> <Setter Property="ItemsPanel"> <Setter.Value> <ItemsPanelTemplate> <WrapPanel Orientation="Vertical" /> </ItemsPanelTemplate> </Setter.Value> </Setter> <Setter Property="BorderThickness" Value="0" /> <Setter Property="Background" Value="Transparent" /> </Style> Here's the code for the ListBox that shows the style correctly: <ListBox x:Name="ColumnsList" Grid.Column="0" Grid.Row="0" Style="{StaticResource CheckBoxListStyle}" BorderThickness="1"> <ListBox.Items> <ListBoxItem>Test</ListBoxItem> <ListBoxItem>Test2</ListBoxItem> <ListBoxItem>Test3</ListBoxItem> </ListBox.Items> </ListBox> Here's the code for the ListBox that ignores the style: <ListBox x:Name="ColumnsList2" Grid.Column="0" Grid.Row="0" Style="{StaticResource CheckBoxListStyle}" BorderThickness="1" ItemsSource="{Binding Source={StaticResource Test1}, Path=Items}"> </ListBox> Hoping someone can help - I'm pretty new to all this and have tried everything I can think of, but everything I've read leads me to believe that setting ItemsSource should have the same outcome as setting the items manually, so I can't see any reason why this would not work. Thanks, AT

    Read the article

< Previous Page | 2 3 4 5 6 7 8 9 10 11 12 13  | Next Page >