We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date

How can I get the colWidth of a hidden column in GDBG?

Model.ColWidths[hiddenFieldName] seems return 0.

1 Reply

AD Administrator Syncfusion Team October 18, 2003 01:10 PM UTC

This is by design. If you want to be able to access the widths of hidden columns, then you will have to do some work. You could catch the ColsHiding event and cache the colwidths there before the columns get hidden. And then use these cached values when you want to retrieve the hidden column width. Or, you could flip the hidden flag (while the grid's drawing is locked), and retrieve the widths in this manner.
private int GetHiddenColWidth(int col)
{
	bool hidden = this.gridDataBoundGrid1.Model.HideCols[col];
	int width = -1;
	if(hidden)
	{
		this.gridDataBoundGrid1.BeginUpdate();
		this.gridDataBoundGrid1.Model.HideCols[col] = false;
		width = this.gridDataBoundGrid1.Model.ColWidths[col];
		this.gridDataBoundGrid1.Model.HideCols[col] = true;
		this.gridDataBoundGrid1.EndUpdate();
	}
	return width;
}

Loader.
Live Chat Icon For mobile
Up arrow icon