This is a migrated thread and some comments may be shown as answers.

how to bind 2nd combo box on selected index of first combo box into Wpf Rad grid

4 Answers 127 Views
GridView
This is a migrated thread and some comments may be shown as answers.
vikas gupta
Top achievements
Rank 1
vikas gupta asked on 28 Nov 2011, 02:59 PM
i have done that task ,now i want bind specific Combo box column of specific row .
my code is like this 
Xml
  <Grid>
        <Grid.Resources>
                       <Style TargetType="telerik:RadComboBox">
                <EventSetter Event="SelectionChanged" Handler="ComboBox_SelectionChanged" />
            </Style>
        </Grid.Resources>
        <UI:ModuleControl x:Name="mdParticipantWI" IsShowIcon="False"
                          Title="Participant Wellness Incentives"
                          Margin="8">


            <Grid>
                <Grid.RowDefinitions>
                    <RowDefinition Height="auto" />
                    <RowDefinition />
                </Grid.RowDefinitions>
                <StackPanel  VerticalAlignment="Top">
                    <TextBlock Name="txtUserName"
                               Style="{StaticResource SectionTitleStyle}" />
                    <TextBlock />
                    <TextBlock Text="Risk Factor Overrides"
                               Style="{StaticResource SectionTitleStyle}" />
                    <StackPanel>
                        <UI:UcToolbar IsShowNewButton="True" IsShowDeleteButton="True" IsShowCancelButton="True" IsShowEditButton="True" IsShowSaveButton="True" x:Name="UcToolbar1"></UI:UcToolbar>
                        <telerik:RadGridView x:Name="grdRiskFactorOverrides"
                                     ShowGroupPanel="False"
                                     Margin="0 8 0 0"
                                     AutoGenerateColumns="false">
                            <telerik:RadGridView.Columns>
                                <telerik:GridViewComboBoxColumn DataMemberBinding="{Binding ewip_id}"
                                    UniqueName="Models"
                                                    IsComboBoxEditable="false"
                                                    Header= "Model"
                                                    HeaderTextAlignment="Center"
                                                    SelectedValueMemberPath="ewip_id"
                                                    DisplayMemberPath="ewip_title" 
                                                    Width="200" />
                                <telerik:GridViewComboBoxColumn DataMemberBinding="{Binding ewrf_id}"
                                    UniqueName="RiskFactors" Name="RiskFactors"
                                                    IsComboBoxEditable="True"
                                                                IsEnabled="True"
                                                              Header= "Risk Factor"
                                                    HeaderTextAlignment="Center"            
                                                    SelectedValueMemberPath="ewrf_id"
                                                    DisplayMemberPath="risk_factor" 
                                                    Width="150" />
                                <telerik:GridViewDataColumn  Header="Reason for Override"
                                                     DataMemberBinding="{Binding reason}"
                                                     Width="*" />
                            </telerik:RadGridView.Columns>
                        </telerik:RadGridView>


                        <!--<UI:MaestroGridView  x:Name="grdRiskFactorOverrides"
                                     ShowGroupPanel="False"
                                     Margin="0 8 0 0"
                                     AutoGenerateColumns="false">
                            <UI:MaestroGridView.Columns>
                                <telerik:GridViewComboBoxColumn DataMemberBinding="{Binding ewip_id}"
                                    UniqueName="Models"
                                                    IsComboBoxEditable="True"
                                                    Header= "Model"
                                                    HeaderTextAlignment="Center"            
                                                    SelectedValueMemberPath="ewip_id"
                                                    DisplayMemberPath="ewip_title" 
                                                    Width="200" />
                                <telerik:GridViewComboBoxColumn DataMemberBinding="{Binding ewrf_id}"
                                    UniqueName="RiskFactors"
                                                    IsComboBoxEditable="True"
                                                    Header= "Risk Factor"
                                                    HeaderTextAlignment="Center"            
                                                    SelectedValueMemberPath="ewrf_id"
                                                    DisplayMemberPath="risk_factor" 
                                                    Width="150" />                                
                                <telerik:GridViewDataColumn  Header="Reason for Override"
                                                     DataMemberBinding="{Binding reason}"
                                                     Width="*" />
                            </UI:MaestroGridView.Columns>
                        </UI:MaestroGridView>-->
                        <telerik:RadDataPager Height="24" />
                    </StackPanel>


                </StackPanel>
            </Grid>
        </UI:ModuleControl>
    </Grid>

coding part:

  Private Sub ComboBox_SelectionChanged(ByVal sender As Object, ByVal e As SelectionChangedEventArgs)
        Dim comboBox As RadComboBox = DirectCast(e.OriginalSource, RadComboBox)
        If comboBox.SelectedValue Is Nothing OrElse comboBox.SelectedValuePath <> "ewip_id" Then
            Return
        End If
        If Not comboBox.SelectedValue Is Nothing Then
            Dim selectedCountry As Int32 = DirectCast(comboBox.SelectedValue, Int32)
            ' Dim test As String = Me.grdRiskFactorOverrides.SelectedItem
            Dim i As Integer = Me.grdRiskFactorOverrides.Items.IndexOf(Me.grdRiskFactorOverrides.SelectedItem)


            Dim objWellnessIncentiveMethods As New WellnessIncentiveMethods
            Dim riskFactorsList As New List(Of MaestroLibrary.riskFactors)
            riskFactorsList = objWellnessIncentiveMethods.fnGetRiskFactors(selectedCountry)
            Dim gridViewComboColumn As New GridViewComboBoxColumn()
            gridViewComboColumn.DataMemberBinding = New System.Windows.Data.Binding("ewrf_id")
            gridViewComboColumn.UniqueName = "RiskFactors"


            Try
                'If DirectCast(grdRiskFactorOverrides.Rows(0).Cells(5).Value, Decimal) > 10 Then
                '    grdRiskFactorOverrides.Rows(0).Cells(5).Value = 10
                'End If
                'DirectCast(Me.grdRiskFactorOverrides.Columns("RiskFactors"), GridViewComboBoxColumn).ItemsSource = riskFactorsList


                Dim countries As GridViewComboBoxColumn = TryCast(Me.grdRiskFactorOverrides.FindName("RiskFactors"), GridViewComboBoxColumn)
                countries.ItemsSource = riskFactorsList(here i want to find clicked row specific column and want to provide item source)





                'Dim aa As GridViewRowDetailsEventArgs
                'Dim countries2 As GridViewComboBoxColumn = TryCast(aa.DetailsElement.FindName("RiskFactors"), GridViewComboBoxColumn)


            Catch ex As Exception


            End Try


            gridViewComboColumn.SelectedValueMemberPath = "ewrf_id"
            gridViewComboColumn.DisplayMemberPath = "risk_factor"


            ' bindComboRiskFactors(selectedCountry)


        End If
    End Sub

i have requested to telerik support team,please help me to solve that issue.if you want to ask any thing regarding that,you can ask

4 Answers, 1 is accepted

Sort by
0
vikas gupta
Top achievements
Rank 1
answered on 29 Nov 2011, 05:44 AM
Please reply,is it possible or not?
0
Vlad
Telerik team
answered on 29 Nov 2011, 07:44 AM
Hi,

 I strongly suggest you to check our documentation and demos related to the combo-box column!

Best wishes,
Vlad
the Telerik team

Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get it now >>

0
vikas gupta
Top achievements
Rank 1
answered on 29 Nov 2011, 10:42 AM
Hello vlad

i am able to find column using below code
DirectCast(Me.radGridView.Columns("Country"), GridViewComboBoxColumn).ItemsSource = RadGridViewSampleData.GetCountries()

i want to find column for a specific row,how can i find column for a specific row(like i want to find column name "Country" into second row of the grid)

Please reply,how can i find?
0
vikas gupta
Top achievements
Rank 1
answered on 29 Nov 2011, 01:17 PM
Hello Telerik support Team

Is it possible to Find column for a specific row into Wpf Rad grid view or not?
Tags
GridView
Asked by
vikas gupta
Top achievements
Rank 1
Answers by
vikas gupta
Top achievements
Rank 1
Vlad
Telerik team
Share this question
or