代码之家  ›  专栏  ›  技术社区  ›  Geeth

列表框内的复选框

  •  0
  • Geeth  · 技术社区  · 15 年前

    如何在列表框中添加复选框。如果ChechBoxList控件不适合更多记录,则通过使用ListBox,用户可以轻松滚动以选择项目。

    吉萨

    3 回复  |  直到 7 年前
        1
  •  4
  •   mplungjan Gvidas    7 年前

    你想要的是

    CheckBoxList .

    Newer CheckBoxList

    一步一步的不错 here .

        2
  •  2
  •   Picrofo Software    12 年前

    怎么样 checkedListBox ?

    <asp:CheckBoxList id="checkboxlist1" runat="server"> 
             <asp:ListItem>Item 1</asp:ListItem>
             <asp:ListItem>Item 2</asp:ListItem>  
             <asp:ListItem>Item 3</asp:ListItem>          
    </asp:CheckBoxList>
    

    访问用户操作中的项目

    void checkboxlist1_Clicked(Object sender, EventArgs e) 
    {          
       if (checkBoxList1.SelectedIndex == 1)
       {
           // DoSomething  
       }      
    }
    
        3
  •  -1
  •   Picrofo Software    12 年前
    <ListBox x:Name="targetList" ItemsSource="{Binding}">
    
    <ListBox.ItemTemplate>
    
    <HierarchicalDataTemplate>
    
    <StackPanel Orientation="Horizontal">
    
    <CheckBox>
    
    <TextBlock Text="{Binding Path=Name}"/>
    
    </CheckBox>
    
    </StackPanel>
    
    </HierarchicalDataTemplate>
    
    </ListBox.ItemTemplate>
    
    </ListBox>