lundi 9 mai 2016

How to get all of listBox marked checkBox?

<Window
xmlns="http://ift.tt/o66D3f"
xmlns:x="http://ift.tt/mPTqtT"
xmlns:d="http://ift.tt/pHvyf2"
xmlns:mc="http://ift.tt/pzd6Lm"
xmlns:local="clr-namespace:WpfApplication1"
xmlns:chartingToolkit="clr-namespace:System.Windows.Controls.DataVisualization.Charting;assembly=System.Windows.Controls.DataVisualization.Toolkit" x:Class="WpfApplication1.MainWindow"
mc:Ignorable="d"
Title="MainWindow" Height="637" Width="1889">

=

    <TabItem/>
</ComboBox>
<TextBox x:Name="txtFilterValue" HorizontalAlignment="Left" Height="23" Margin="225,409,0,0" TextWrapping="Wrap" Text="TextBox" VerticalAlignment="Top" Width="120"/>
<GroupBox x:Name="groupBox" Header="GroupBox" HorizontalAlignment="Left" Margin="225,10,0,0" VerticalAlignment="Top" Width="1110" Height="385">
    <DataGrid x:Name="dataGrid" HorizontalAlignment="Left" Margin="245,105,0,0" VerticalAlignment="Top" Height="230" Width="645"/>
</GroupBox>
<ListBox x:Name="listBox"   HorizontalAlignment="Left" Height="385" Margin="10,10,0,0" VerticalAlignment="Top" Width="230" FontFamily="Segoe UI Black" Grid.Column="10">


    <ListBox.ItemTemplate >
        <DataTemplate>
            <CheckBox x:Name="qqq"  Content="{Binding }" IsChecked="{Binding IsChecked}" Click="CheckBox_Click"/>
        </DataTemplate>
    </ListBox.ItemTemplate>


</ListBox>


</Grid>





 private void CheckBox_Click(object sender, RoutedEventArgs e)
{

var cb = sender as CheckBox;
var item = cb.IsChecked;
listBox.SelectedItem = item;

 if (listBox.SelectedIndex==0) return;



string query = "SELECT NON EMPTY { [Measures].[Число Подписки] } ON COLUMNS, NON EMPTY {(";




foreach (string i in listBox.Checked)
{
    query += " " + i.ToString() + ".ALLMEMBERS *";

}


query = query.Remove(query.Length - 2);






    query += " )} DIMENSION PROPERTIES MEMBER_CAPTION, MEMBER_UNIQUE_NAME ON ROWS FROM [Почта] CELL PROPERTIES VALUE, BACK_COLOR, FORE_COLOR, FORMATTED_VALUE, FORMAT_STRING, FONT_NAME, FONT_SIZE, FONT_FLAGS";
    UpdateChart(query);


}

It turns out only to withdraw all at once, and how to do that would be deduced by one (ie. If checkBox == true, then we conclude that measurement of the cube)

Aucun commentaire:

Enregistrer un commentaire