1 Replies - 5682 Views - Last Post: 28 June 2011 - 04:41 PM

#1 hardeepkchawla  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 1
  • Joined: 19-March 11

Dynamically Changing Combobox to TextBox in datagrid in Silverlight 4

Posted 19 March 2011 - 03:09 AM

I m making an application in silverlight 4 .I am facing a problem,I need to change a particular combobox into textbox programmatically when a particular column value(using combobox) of the same row is changed.I need to change this on event cellEditEnded.
Please note that I need to change celleditingtemplate combobox to textbox not celltemplate textblock .
This my Column where I need to take the decision of its combo box selected value.

<sdk:DataGridTemplateColumn  Header="Instruction Type" CanUserResize="False" CanUserReorder="False">
         <sdk:DataGridTemplateColumn.CellTemplate>
         DataTemplate>
          <TextBlock  Margin="2" Text="{Binding operationType}" />
            </DataTemplate>
</sdk:DataGridTemplateColumn.CellTemplate>
<sdk:DataGridTemplateColumn.CellEditingTemplate>
<DataTemplate>
<ComboBox   x:Name="instruction" />
</DataTemplate>
</sdk:DataGridTemplateColumn.CellEditingTemplate>
</sdk:DataGridTemplateColumn>
	
This Column comboBox need to change  to textbox here:

<sdk:DataGridTemplateColumn Header="Destination">
<sdk:DataGridTemplateColumn.CellTemplate>
<DataTemplate>
<TextBlock Margin="2" Text="{Binding destination}" />
</DataTemplate>
</sdk:DataGridTemplateColumn.CellTemplate>
<sdk:DataGridTemplateColumn.CellEditingTemplate>
<DataTemplate>
<ComboBox  x:Name="destination"/>
</DataTemplate>
</sdk:DataGridTemplateColumn.CellEditingTemplate>
</sdk:DataGridTemplateColumn>



  public class Instruction
    {
        public string operationType { get; set; }
        public string destination { get; set; }
    }

private void myGrid_CellEditEnded(object sender, DataGridCellEditEndedEventArgs e)
        {
			  DataGrid obj = (DataGrid)sender;
			Instruction obj1 = (Instruction)obj.SelectedItem;

if (e.Column.Header.ToString() == "Instruction Type")
            {
		if (obj1.operationType == "ADD" || obj1.operationType == "SUB")
                {

			// Here I need Require Code ????/
  }

}
}

Attached image(s)

  • Attached Image


Is This A Good Question/Topic? 0
  • +

Replies To: Dynamically Changing Combobox to TextBox in datagrid in Silverlight 4

#2 MKunstman  Icon User is offline

  • D.I.C Head

Reputation: 8
  • View blog
  • Posts: 193
  • Joined: 26-October 09

Re: Dynamically Changing Combobox to TextBox in datagrid in Silverlight 4

Posted 28 June 2011 - 04:41 PM

I am not sure if this would remedy the issue but you likely could nest a grid within that cell which would then be home to a stack panel which has a combo box and a text box (which is seen is set to the previous selection). Basically your selection could then dictate which portion of the stack panel is visible and thus both are in the same cell but only active based on the selection in the combo box.
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1