Grid Grouping Control

is there a way to freeze the grouping grid caption text when scrolling to the right.

thanks
prem

1 Reply

AD Administrator Syncfusion Team September 22, 2006 09:20 AM UTC

Hi Prem,

Yes. You need to handle the TableControlDrawCell event and draw the GridCaption cell text using DrawString method. Below is a code snippet

//Form Load.
this.grid.TableControl.HScrollPixelPosChanged +=new GridScrollPositionChangedEventHandler(HScrollPixelPosChanged);

private void TableControlDrawCell(object sender, GridTableControlDrawCellEventArgs e)
{
GridTableCellStyleInfo style = e.Inner.Style as GridTableCellStyleInfo;

if( style.TableCellIdentity.TableCellType == GridTableCellType.GroupCaptionCell
&& e.Inner.ColIndex ==0 && e.TableControl.TableDescriptor.Name == "ParentTable" )
{
e.Inner.Cancel = true;
string s = e.Inner.Style.Text;
e.Inner.Style.Text = string.Empty;

Rectangle rect = e.Inner.Bounds;
rect.Location = new Point(0,rect.Y);

e.Inner.Renderer.Draw(e.Inner.Graphics ,e.Inner.Bounds,e.Inner.RowIndex,e.Inner.ColIndex,e.Inner.Style );
e.Inner.Graphics.DrawString(s,e.Inner.Style.GdipFont,new SolidBrush(e.Inner.Style.TextColor),rect);

e.Inner.Style.Text = s;
}
}

private void HScrollPixelPosChanged(object sender, GridScrollPositionChangedEventArgs e)
{
GridTableControl tc = sender as GridTableControl;
tc.RefreshRange(GridRangeInfo.Row(1));
}

Thanks,
Haneef

GGCCaptioncellDraw.zip

Loader.
Up arrow icon