Resize to fit a Grid control column
Hi,
I want to resize to fit the column width by longest text of that particular column when double clicking on the column header border (want to work as normal windows like grid).
plz help me out abt this.
I want to resize to fit the column width by longest text of that particular column when double clicking on the column header border (want to work as normal windows like grid).
plz help me out abt this.
SIGN IN To post a reply.
6 Replies
JJ
Jisha Joy
Syncfusion Team
January 2, 2009 05:42 AM UTC
Hi Ali,
To resize to fit a particular range of cells (could be a row, col or table or several rows or whatever), you use the ResizeToFit method which is a member of the GridControl.ColWidths and GridControl.RowHeights classes.
So, to resize the widths of all cells in column 1, use
this.gridControl1.ColWidths.ResizeToFit(GridRangeInfo.Col(1));
To resize the heights of the range (1,1) to (4,5), use
this.gridControl1.RowHeights.ResizeToFit( GridRangeInfo.Cells(1,1,4,5));
Please let me know if this helps.
Regards,
Jisha
AL
ali
January 8, 2009 09:59 AM UTC
Hi Jisha,
Thanks for your valuable reply.
I already tried this ResizeToFit method. and it was working. but i need to do this resize when double clicking on Column divider. for that in which event i should write the line of code.
thank again.
>
Hi Ali,
To resize to fit a particular range of cells (could be a row, col or table or several rows or whatever), you use the ResizeToFit method which is a member of the GridControl.ColWidths and GridControl.RowHeights classes.
So, to resize the widths of all cells in column 1, use
this.gridControl1.ColWidths.ResizeToFit(GridRangeInfo.Col(1));
To resize the heights of the range (1,1) to (4,5), use
this.gridControl1.RowHeights.ResizeToFit( GridRangeInfo.Cells(1,1,4,5));
Please let me know if this helps.
Regards,
Jisha
JJ
Jisha Joy
Syncfusion Team
January 9, 2009 10:38 AM UTC
Hi Ali,
You can handle ResizingColumns event of GridControl and can check for the e.Reason. Please see the code:
this.gridControl1.ResizingColumns += new Syncfusion.Windows.Forms.Grid.GridResizingColumnsEventHandler(gridControl1_ResizingColumns);
void gridControl1_ResizingColumns(object sender, Syncfusion.Windows.Forms.Grid.GridResizingColumnsEventArgs e)
{
if(e.Reason == Syncfusion.Windows.Forms.Grid.GridResizeCellsReason.DoubleClick)
MessageBox.Show("Fired");
}
Regards,
Jisha
You can handle ResizingColumns event of GridControl and can check for the e.Reason. Please see the code:
this.gridControl1.ResizingColumns += new Syncfusion.Windows.Forms.Grid.GridResizingColumnsEventHandler(gridControl1_ResizingColumns);
void gridControl1_ResizingColumns(object sender, Syncfusion.Windows.Forms.Grid.GridResizingColumnsEventArgs e)
{
if(e.Reason == Syncfusion.Windows.Forms.Grid.GridResizeCellsReason.DoubleClick)
MessageBox.Show("Fired");
}
Regards,
Jisha
AL
ali
January 12, 2009 09:35 AM UTC
Hi Jisha,
Thank you for your support and help.
I have tried with the code wich u have mentioned earlier.
Here is my code
private void syncGrdCtrl1_ResizingColumns(object sender, GridResizingColumnsEventArgs e)
{
if (e.Reason == GridResizeCellsReason.DoubleClick)
{
syncGrdCtrl1.ColWidths.ResizeToFit(GridRangeInfo.Col(e.Columns.Left));
}
}
for getting the column Index i took the e.Columns.Left ( as well as the .Right).
the event is firing but the columns still remain without any change. I even tried with a fixed column Index (instead of e.Columns.Left, i have given 2).
Thanks,
Ali PP
>Hi Ali,
You can handle ResizingColumns event of GridControl and can check for the e.Reason. Please see the code:
this.gridControl1.ResizingColumns += new Syncfusion.Windows.Forms.Grid.GridResizingColumnsEventHandler(gridControl1_ResizingColumns);
void gridControl1_ResizingColumns(object sender, Syncfusion.Windows.Forms.Grid.GridResizingColumnsEventArgs e)
{
if(e.Reason == Syncfusion.Windows.Forms.Grid.GridResizeCellsReason.DoubleClick)
MessageBox.Show("Fired");
}
Regards,
Jisha
Thank you for your support and help.
I have tried with the code wich u have mentioned earlier.
Here is my code
private void syncGrdCtrl1_ResizingColumns(object sender, GridResizingColumnsEventArgs e)
{
if (e.Reason == GridResizeCellsReason.DoubleClick)
{
syncGrdCtrl1.ColWidths.ResizeToFit(GridRangeInfo.Col(e.Columns.Left));
}
}
for getting the column Index i took the e.Columns.Left ( as well as the .Right).
the event is firing but the columns still remain without any change. I even tried with a fixed column Index (instead of e.Columns.Left, i have given 2).
Thanks,
Ali PP
>Hi Ali,
You can handle ResizingColumns event of GridControl and can check for the e.Reason. Please see the code:
this.gridControl1.ResizingColumns += new Syncfusion.Windows.Forms.Grid.GridResizingColumnsEventHandler(gridControl1_ResizingColumns);
void gridControl1_ResizingColumns(object sender, Syncfusion.Windows.Forms.Grid.GridResizingColumnsEventArgs e)
{
if(e.Reason == Syncfusion.Windows.Forms.Grid.GridResizeCellsReason.DoubleClick)
MessageBox.Show("Fired");
}
Regards,
Jisha
AL
ali
January 12, 2009 10:20 AM UTC
Hi Jisha..
Thanks for your suport.
finally i have done it..
here is my code
private void syncGrdCtrl1_ResizingColumns(object sender, GridResizingColumnsEventArgs e)
{
if (e.Reason == GridResizeCellsReason.DoubleClick)
{
int iColIndx = e.Columns.Left;
if (syncGrdCtrl1.ColWidths.IsDefault(iColIndx))
{
syncGrdCtrl1.ColWidths.ResizeToFit(GridRangeInfo.Col(iColIndx));
e.Cancel = true;
}
else
{
e.Cancel = false;
}
}
}
Thanks n Regards
Ali PP
>Hi Jisha,
Thank you for your support and help.
I have tried with the code wich u have mentioned earlier.
Here is my code
private void syncGrdCtrl1_ResizingColumns(object sender, GridResizingColumnsEventArgs e)
{
if (e.Reason == GridResizeCellsReason.DoubleClick)
{
syncGrdCtrl1.ColWidths.ResizeToFit(GridRangeInfo.Col(e.Columns.Left));
}
}
for getting the column Index i took the e.Columns.Left ( as well as the .Right).
the event is firing but the columns still remain without any change. I even tried with a fixed column Index (instead of e.Columns.Left, i have given 2).
Thanks,
Ali PP
>Hi Ali,
You can handle ResizingColumns event of GridControl and can check for the e.Reason. Please see the code:
this.gridControl1.ResizingColumns += new Syncfusion.Windows.Forms.Grid.GridResizingColumnsEventHandler(gridControl1_ResizingColumns);
void gridControl1_ResizingColumns(object sender, Syncfusion.Windows.Forms.Grid.GridResizingColumnsEventArgs e)
{
if(e.Reason == Syncfusion.Windows.Forms.Grid.GridResizeCellsReason.DoubleClick)
MessageBox.Show("Fired");
}
Regards,
Jisha
Thanks for your suport.
finally i have done it..
here is my code
private void syncGrdCtrl1_ResizingColumns(object sender, GridResizingColumnsEventArgs e)
{
if (e.Reason == GridResizeCellsReason.DoubleClick)
{
int iColIndx = e.Columns.Left;
if (syncGrdCtrl1.ColWidths.IsDefault(iColIndx))
{
syncGrdCtrl1.ColWidths.ResizeToFit(GridRangeInfo.Col(iColIndx));
e.Cancel = true;
}
else
{
e.Cancel = false;
}
}
}
Thanks n Regards
Ali PP
>Hi Jisha,
Thank you for your support and help.
I have tried with the code wich u have mentioned earlier.
Here is my code
private void syncGrdCtrl1_ResizingColumns(object sender, GridResizingColumnsEventArgs e)
{
if (e.Reason == GridResizeCellsReason.DoubleClick)
{
syncGrdCtrl1.ColWidths.ResizeToFit(GridRangeInfo.Col(e.Columns.Left));
}
}
for getting the column Index i took the e.Columns.Left ( as well as the .Right).
the event is firing but the columns still remain without any change. I even tried with a fixed column Index (instead of e.Columns.Left, i have given 2).
Thanks,
Ali PP
>Hi Ali,
You can handle ResizingColumns event of GridControl and can check for the e.Reason. Please see the code:
this.gridControl1.ResizingColumns += new Syncfusion.Windows.Forms.Grid.GridResizingColumnsEventHandler(gridControl1_ResizingColumns);
void gridControl1_ResizingColumns(object sender, Syncfusion.Windows.Forms.Grid.GridResizingColumnsEventArgs e)
{
if(e.Reason == Syncfusion.Windows.Forms.Grid.GridResizeCellsReason.DoubleClick)
MessageBox.Show("Fired");
}
Regards,
Jisha
JJ
Jisha Joy
Syncfusion Team
January 13, 2009 05:53 AM UTC
Hi Ali,
Thank you for your update. Glad to hear that issue has been resolved.
Regards.
Jisha
Thank you for your update. Glad to hear that issue has been resolved.
Regards.
Jisha
SIGN IN To post a reply.
- 6 Replies
- 2 Participants
-
AL ali
- Jan 1, 2009 12:06 PM UTC
- Jan 13, 2009 05:53 AM UTC