Posted 16 October 2017, 8:30 am EST
I need for the user to be able to edit the column headers in a flex grid. I’ve tried
fg.ColumnHeaders.Rows(0).IsReadOnly = False
but it does not allow editing.
Thanks for your help.
Forums Home / ComponentOne / WPF Edition
Posted by: terry.stringer on 16 October 2017, 8:30 am EST
Posted 16 October 2017, 8:30 am EST
I need for the user to be able to edit the column headers in a flex grid. I’ve tried
fg.ColumnHeaders.Rows(0).IsReadOnly = False
but it does not allow editing.
Thanks for your help.
Posted 17 October 2017, 8:35 pm EST
Hi,
You can try to use custom cell factory for achieving your requirement as:
public partial class MainWindow : Window
{
public MainWindow()
{
InitializeComponent();
}
private void Window_Loaded(object sender, RoutedEventArgs e)
{
flexgrid.CellFactory = new TextBoxHeader();
}
}
public class TextBoxHeader : CellFactory
{
public override void CreateColumnHeaderContent(C1FlexGrid grid, Border bdr, CellRange range)
{
var col = grid.Columns[range.Column];
base.CreateColumnHeaderContent(grid, bdr, range);
TextBox tb = new TextBox();
var headertext = grid.Columns[range.Column].Header;
if (headertext != null)
{
tb.Text = headertext;
}
bdr.Child = null;
tb.Margin = new Thickness(0);
bdr.Padding = new Thickness(0);
tb.HorizontalAlignment = HorizontalAlignment.Stretch;
tb.VerticalAlignment = VerticalAlignment.Stretch;
bdr.Child = tb;
}
}
Please read the docs for more information.
http://help.grapecity.com/componentone/NetHelp/c1flexgridwpfsilv/FlexGrid-for-WPF-Silverlight.html
Thanks,
Singh Sonu