Hi.......
I have a wpf form which have 3 controls. One gridview which have bind record from database such as employee record one text box and one button. When user enter any value in textbox and when he click button then content of textbox is searched in gridview and which cell of gridview contains letter of textbox the background color of that cell is changed. How can I perform this task. Please help me. Its urgent.
Thanks you.

CrishRank #1,487 · 1.1K reputationPosted Apr 22, 2011, 2:12 AM EDT
grid.BeginInit(); grid.Columns.Clear(); int i = 0; var glass_brush = new SolidColorBrush(Color.FromArgb(255,0,0,0)); foreach (var db_col in query.FieldNames) { var template = new DataTemplate(); var elemFactory = new FrameworkElementFactory(typeof(TextBox)); elemFactory.SetBinding(TextBox.TextProperty, new Binding(String.Format("Visual[{0}]", i))); // make the background transparent -- it does not work though elemFactory.SetValue(TextBlock.BackgroundProperty,glass_brush); template.VisualTree = elemFactory; var col = new DataGridTemplateColumn(); col.CellTemplate = template; col.IsReadOnly = true; col.Header = db_col; grid.Columns.Add(col); ++i; } { grid.Items.Clear(); foreach (var db_row in diffs) { var row = new DataGridRow(); row.Item = db_row.Item1; row.Background = colors[db_row.Item2]; grid.Items.Add(row); } } grid.IsReadOnly = true; grid.EndInit();