i am having combobox in the each cells of the datagrid when i select others from
the combobox i want to add textbox in the same cell of that datagrid if anyone knows how to do it give some code sample

Recommended Answers

All 4 Replies

You will attract alot more interest in helping if you show us what you have so far and what you have tried.

i am having two combobox in each cells of the datagrid and i bind the itmes in the combobox from the database.if i select the item others from combobox i
want to add textbox dynamically to that cell.i can able to add textbox in the
datatemplate and make them visible when others option is selected in the combobox but the problem is it will set gap in the datagrid cell when textbox is in hidden state here is xaml.

<DataGridTemplateColumn.CellEditingTemplate>
                        <DataTemplate>

                                <ComboBox x:Name="monday" Width="30"   ItemsSource="{Binding  Path=Subjects}" DataContext="{Binding RelativeSource={RelativeSource Mode=FindAncestor, AncestorType=UserControl}}" SelectedItem="{Binding SelectedCollectionItem,Mode=TwoWay}"     Loaded="monday_Loaded" SelectionChanged="monday_SelectionChanged"></ComboBox>
                                <TextBox x:Name="monothers" Visibility="Collapsed"  Width="30" TextChanged="monothers_TextChanged"></TextBox>//**It will gives gap between when it is in hidden state**
                                <ComboBox x:Name="staff" Width="30"  ItemsSource="{Binding  Path=mondstaff}"  DataContext="{Binding RelativeSource={RelativeSource Mode=FindAncestor, AncestorType=UserControl}}" SelectedItem="{Binding SelectedCollectionItem1,Mode=TwoWay}"  Loaded="staff_Loaded" SelectionChanged="staff_SelectionChanged"></ComboBox>
                                <!--<ComboBox x:Name="staff" Width="50" Loaded="staff_Loaded"></ComboBox>-->
                            </StackPanel>
                        </DataTemplate>

                    </DataGridTemplateColumn.CellEditingTemplate>

"i can able to add textbox

Don't you mean "i'm able to add to the textbox?" please work on your english language and grammar so it can be easier to comunicate your problems here.

Try setting the width to 0 and change it back when disaplying it

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.