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
close icon

Is there a way to make the dropdown panel size to be equal to covered cell size?

Hi,

I have a grid with the covered cells. Now the problem is I have a dropdown cell type. The width of the dropdown is by default equal to the longest string in the dropdown list.

In case of booleans where the options are Yes and No only the width of the dropdown is too small and looks odd as compared to the width of the covered cell associated with it. Is there a way to set the width of the dropdown to be equal to the size of the covered cell with which it is associated to.

Also is there any way to specify the width of the dropdown.

Thanks and Regards
Prashant Agarwal

4 Replies

AD Administrator Syncfusion Team December 11, 2006 04:01 AM UTC

Hi Prashant,

If you want to change the width of the DropDown in a GridListControl CellType, then you have to handle the CurrentCellShowingDropDown event, and set e.Size there. (Only the width is applicable in a GridListControl celltype, the height is determined by the DropDownRows parameter.


private void grid_CurrentCellShowingDropDown(object sender, GridCurrentCellShowingDropDownEventArgs e)
{
GridCurrentCell cc = this.grid.CurrentCell;
if(cc.ColIndex == 5 ) //dropdown column
{
GridDropDownGridListControlCellRenderer cr = cc.Renderer as GridDropDownGridListControlCellRenderer;
if(cr != null)
{ //change teh height
((GridDropDownGridListControlPart)cr.ListControlPart).DropDownRows = 10;
//change the width
e.Size = new Size(400, e.Size.Height);
}
}
}

Best Regards,
Haneef


PR Prashant December 11, 2006 09:22 AM UTC

Hi Haneef,

Thanks for the response. But is there not a way to set the size equivalent to the size of the covered cell.

Thanks and Regards
Prashant Agarwal

>Hi Prashant,

If you want to change the width of the DropDown in a GridListControl CellType, then you have to handle the CurrentCellShowingDropDown event, and set e.Size there. (Only the width is applicable in a GridListControl celltype, the height is determined by the DropDownRows parameter.


private void grid_CurrentCellShowingDropDown(object sender, GridCurrentCellShowingDropDownEventArgs e)
{
GridCurrentCell cc = this.grid.CurrentCell;
if(cc.ColIndex == 5 ) //dropdown column
{
GridDropDownGridListControlCellRenderer cr = cc.Renderer as GridDropDownGridListControlCellRenderer;
if(cr != null)
{ //change teh height
((GridDropDownGridListControlPart)cr.ListControlPart).DropDownRows = 10;
//change the width
e.Size = new Size(400, e.Size.Height);
}
}
}

Best Regards,
Haneef


AD Administrator Syncfusion Team December 11, 2006 09:40 AM UTC

Hi Prashant,

You can use the Renderer.GetCellBoundsCore() method to get the size of the covered cells in a grid. Here is a code snippet to show this.

private void gridControl1_CurrentCellShowingDropDown(object sender, GridCurrentCellShowingDropDownEventArgs e)
{
GridControl grid = sender as GridControl;
GridCurrentCell cc = grid.CurrentCell;
GridRangeInfo range = GridRangeInfo.Cell(cc.RowIndex,cc.ColIndex);
if( grid.Model.CoveredRanges.Ranges.AnyRangeContains(range))
{
int width = cc.Renderer.GetCellBoundsCore(cc.RowIndex,cc.ColIndex).Width;
e.Size= new Size(width,e.Size.Height);
}
}

Here is a sample.
GCCoveredCells.zip

Best Regards,
Haneef


PR Prashant December 11, 2006 05:18 PM UTC

Hi Haneef,

Thanks for the response. Thats what I was needing.

Thanks and Regards
Prashant Agarwal

>Hi Prashant,

You can use the Renderer.GetCellBoundsCore() method to get the size of the covered cells in a grid. Here is a code snippet to show this.

private void gridControl1_CurrentCellShowingDropDown(object sender, GridCurrentCellShowingDropDownEventArgs e)
{
GridControl grid = sender as GridControl;
GridCurrentCell cc = grid.CurrentCell;
GridRangeInfo range = GridRangeInfo.Cell(cc.RowIndex,cc.ColIndex);
if( grid.Model.CoveredRanges.Ranges.AnyRangeContains(range))
{
int width = cc.Renderer.GetCellBoundsCore(cc.RowIndex,cc.ColIndex).Width;
e.Size= new Size(width,e.Size.Height);
}
}

Here is a sample.
GCCoveredCells.zip

Best Regards,
Haneef

Loader.
Live Chat Icon For mobile
Up arrow icon