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. (Last updated on : Nov 16th 2018).
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

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

Thread ID:

Created:

Updated:

Platform:

Replies:

53184 Dec 10,2006 02:23 PM UTC Dec 11,2006 05:18 PM UTC WinForms 4
loading
Tags: GridControl
Prashant
Asked On December 10, 2006 02:23 PM UTC

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

Administrator [Syncfusion]
Replied On 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

Prashant
Replied On 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

Administrator [Syncfusion]
Replied On 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

Prashant
Replied On 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

CONFIRMATION

This post will be permanently deleted. Are you sure you want to continue?

Sorry, An error occured while processing your request. Please try again later.

Warning Icon You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.Close Icon

;