Results 1 to 1 of 1

Thread: WPF Datagrid - Adding Events to columns

Threaded View

  1. #1

    Thread Starter
    New Member
    Join Date
    Jun 2009
    Posts
    1

    WPF Datagrid - Adding Events to columns

    Hi

    I am having a problem with my datagrid.
    I need to add an enevt to my column so that when the user selects one ot the 3 checkboxes, the remaining 2 get unchecked

    here is the code
    Code:
        <Grid Height="287" Width="424">
            <Border BorderThickness="10" BorderBrush="CadetBlue" CornerRadius="45" MouseRightButtonDown="Border_MouseRightButtonDown" MouseLeftButtonDown="Border_MouseLeftButtonDown" Margin="2,0,40,0">
            <Border.Background>
                <SolidColorBrush Color="white" />
            </Border.Background>
            <my:DataGrid Margin="8,0,8,10" Name="DataGrid1"  AutoGenerateColumns="False" ItemsSource="{Binding}" RowDetailsVisibilityMode="Visible" Height="207" Width="335">
                    <my:DataGrid.Columns>
                        <my:DataGridTextColumn Header="Home" Binding="{Binding Path=home}"/>
                        <my:DataGridCheckBoxColumn Header="H" Binding="{Binding Path=hw}"  Mouse.MouseUp="DataGridCheckBoxColumn_MouseUp"/>
                        <my:DataGridCheckBoxColumn Header="D" Binding="{Binding Path=draw}"/>
                        <my:DataGridCheckBoxColumn Header="A" Binding="{Binding Path=awayw}"/>
                        <my:DataGridTextColumn Header="Away" Binding="{Binding Path=away}"/>
                        <my:DataGridTextColumn Header="Time" Binding="{Binding Path=heurematch}"/>
                    </my:DataGrid.Columns>
                </my:DataGrid>
            </Border>
            <Button Height="23" Margin="132,0,182,16" Name="Button1"  VerticalAlignment="Bottom">Valider</Button>
        </Grid>
    
       ConnectDatabase()
    
            Dim cmd As New MySql.Data.MySqlClient.MySqlCommand("SELECT id, DATEDIFF(date_limite, NOW()) as reste,DATE_FORMAT( date_limite, '&#37;D %M %Y') as date_limite, competition_name FROM competition_public WHERE idsport=1 And idchampionnat=15  ORDER BY reste LIMIT 0,1;", conn)
            Dim dat As MySql.Data.MySqlClient.MySqlDataReader
            Dim idCompet As Integer
    
            dat = cmd.ExecuteReader
            Do While dat.Read()
                idCompet = IIf(dat("id") <> 0, dat("id"), 0)
            Loop
            dat.Close()
    
            Dim sql As New MySql.Data.MySqlClient.MySqlCommand
            'Dim query = "SELECT c1.equipe as home, c1.id as homeId, c2.equipe as away, c2.id as awayId, matchs.heurematch, matchs.id as idM FROM competition_public_match AS compet "
            'query &= " INNER JOIN matchs_soccer AS matchs ON matchs.id=compet.idmatch "
            'query &= " INNER JOIN clubs as c1 ON c1.id=matchs.h_id And c1.idsport=1 "
            'query &= " INNER JOIN clubs as c2 ON c2.id=matchs.v_id And c2.idsport=1 "
            'query &= " WHERE compet.idcompetition = " & idCompet
    
            Dim query = "SELECT c1.equipe as home, 0 as hw,0 as awayw,0 as draw,c2.equipe as away, matchs.heurematch FROM competition_public_match AS compet "
            query &= " INNER JOIN matchs_soccer AS matchs ON matchs.id=compet.idmatch "
            query &= " INNER JOIN clubs as c1 ON c1.id=matchs.h_id And c1.idsport=1 "
            query &= " INNER JOIN clubs as c2 ON c2.id=matchs.v_id And c2.idsport=1 "
            query &= " WHERE compet.idcompetition = " & idCompet
    
            sql.CommandText = query
            sql.Connection = conn
            'Dim sqlD As MySql.Data.MySqlClient.MySqlDataReader = sql.ExecuteReader
            Dim ds As New System.Data.DataSet
            Dim sqla As New MySql.Data.MySqlClient.MySqlDataAdapter
    
            sqla.SelectCommand = sql
            sqla.Fill(ds, "users")
            Dim w3 As New grille
    
            Dim x As Integer
            Dim myMusic As New ObservableCollection(Of match)()
            For x = 0 To ds.Tables("users").Rows.Count - 1
                myMusic.Add(New match(ds.Tables("users").Rows(x)("home"), ds.Tables("users").Rows(x)("hw"), ds.Tables("users").Rows(x)("draw"), ds.Tables("users").Rows(x)("awayw"), ds.Tables("users").Rows(x)("away"), ds.Tables("users").Rows(x)("heurematch")))
            Next
    
            m_orders = ds.Tables("users")
            w3.DataGrid1.ItemsSource = myMusic
    
            w3.Show()
    thanking you in anticipation
    Last edited by si_the_geek; Jun 13th, 2009 at 06:05 AM. Reason: added Code tags

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width