Sanal Rajan

Sanal Rajan

  • 1.5k
  • 174
  • 2.7k

Add Check box for dynamic sdk:datagrid header

May 18 2017 12:40 AM
HistRepcolumnName.Add(ResourceFile.SrNoLevel);
HistRepcolumnName.Add(ResourceFile.RepNameLabel);  
HistRepcolumnName.Add(ResourceFile.Date);
 HistRepcolumnName.Add(ResourceFile.AircraftLabel);
 HistRepcolumnName.Add(ResourceFile.Description); 
HistRepcolumnName.Add(ResourceFile.PerDiemLabel); 
HistRepcolumnName.Add(ResourceFile.DailyFeeLabel);
Binding binding = new Binding(); 
 foreach (var ColumnHeader in HistRepcolumnName) 
{ 
DataGridTemplateColumn templateColumn = new DataGridTemplateColumn();                        templateColumn.Header = ColumnHeader; #region Flag 1 if (Flag == 1 || Flag == 2) { //if (Status.ToUpper() != "PAID" && Status.ToUpper() != "OPEN") // { //} //else //{ string Str = "SrNo"; if (index == 0) { Str = "SrNo"; StringBuilder CellTemp = new StringBuilder(); CellTemp.Append("<DataTemplate "); CellTemp.Append("xmlns='http://schemas.microsoft.com/winfx/"); CellTemp.Append("2006/xaml/presentation' "); CellTemp.Append("xmlns:x='http://schemas.microsoft.com/winfx/2006/xaml' "); CellTemp.Append("xmlns:local = 'clr-namespace:System.Windows.Controls"); CellTemp.Append(";assembly=System.Windows.Controls.Toolkit'>"); CellTemp.Append("<TextBlock "); CellTemp.Append("Text ='{Binding Path=" + Str + "}'   Style='{StaticResource ContentTextStyle}' IsHitTestVisible='False' "); CellTemp.Append("/>"); CellTemp.Append("</DataTemplate>");                                 templateColumn.CellTemplate = (DataTemplate)XamlReader.Load(CellTemp.ToString());                                 dgvRepAdviceList.Columns.Add(templateColumn); } else if (index == 1) { Str = "RepName"; StringBuilder CellTemp = new StringBuilder(); CellTemp.Append("<DataTemplate "); CellTemp.Append("xmlns='http://schemas.microsoft.com/winfx/"); CellTemp.Append("2006/xaml/presentation' "); CellTemp.Append("xmlns:x='http://schemas.microsoft.com/winfx/2006/xaml' "); CellTemp.Append("xmlns:local = 'clr-namespace:System.Windows.Controls"); CellTemp.Append(";assembly=System.Windows.Controls.Toolkit'>"); CellTemp.Append("<TextBlock "); CellTemp.Append("Text ='{Binding Path=" + Str + ",Mode=TwoWay,NotifyOnValidationError=True, ValidatesOnExceptions=True}'  Style='{StaticResource ContentTextStyle}' IsHitTestVisible='True' "); CellTemp.Append("Margin='4'/>"); CellTemp.Append("</DataTemplate>"); StringBuilder CellETemp = new StringBuilder(); CellETemp.Append("<DataTemplate "); CellETemp.Append("xmlns='http://schemas.microsoft.com/winfx/"); CellETemp.Append("2006/xaml/presentation' "); CellETemp.Append("xmlns:x='http://schemas.microsoft.com/winfx/2006/xaml' "); CellETemp.Append("xmlns:local = 'clr-namespace:System.Windows.Controls"); CellETemp.Append(";assembly=System.Windows.Controls.Toolkit'>"); CellETemp.Append("<TextBlock "); CellETemp.Append("Text ='{Binding Path=" + Str + ",Mode=TwoWay,NotifyOnValidationError=True, ValidatesOnExceptions=True}'  Style='{StaticResource ContentTextStyle}'   IsHitTestVisible='False' "); CellETemp.Append("Margin='4'/>"); CellETemp.Append("</DataTemplate>");                                 templateColumn.CellTemplate = (DataTemplate)XamlReader.Load(CellTemp.ToString());                                 templateColumn.CellEditingTemplate = (DataTemplate)XamlReader.Load(CellETemp.ToString());                                 dgvRepAdviceList.Columns.Add(templateColumn); } #endregion } }
if (index == 0) 
{ 
Str = "SrNo"; 
StringBuilder CellTemp = new StringBuilder();
 CellTemp.Append("<DataTemplate "); 
CellTemp.Append("xmlns='http://schemas.microsoft.com/winfx/");
 CellTemp.Append("2006/xaml/presentation' "); 
CellTemp.Append("xmlns:x='http://schemas.microsoft.com/winfx/2006/xaml' "); 
CellTemp.Append("xmlns:local = 'clr-namespace:System.Windows.Controls"); 
CellTemp.Append(";assembly=System.Windows.Controls.Toolkit'>"); 
CellTemp.Append("<TextBlock "); 
CellTemp.Append("Text ='{Binding Path=" + Str + "}'   Style='{StaticResource ContentTextStyle}' IsHitTestVisible='False' "); CellTemp.Append("/>"); 
CellTemp.Append("</DataTemplate>");      
templateColumn.CellTemplate = (DataTemplate)XamlReader.Load(CellTemp.ToString());                                 dgvRepAdviceList.Columns.Add(templateColumn); } 
.....



Answers (1)