Click here to Skip to main content
15,887,746 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
Hi.
I want to make a custom DataGridViewCell like a DataGridViewNumericUpDownCell

I have the following classes:
public class DataGridViewNumericUpDownColumn : DataGridViewTextBoxColumn
{
    //...
}
public class DataGridViewNumericUpDownCell : DataGridViewTextBoxCell
{
    //...
}
class NumericEditingControl : NumericUpDown, IDataGridViewEditingControl
{
    //...
}


Everything works great, except for the fact that the editing control doesn't expand beyond the cell bounds. How could I do this?

This image can make you better understand my issue: http://yfrog.com/12idatagridvieweditingconj
Posted
Updated 29-Jun-10 11:18am
v2

1 solution

FOUND IT!!
public override void PositionEditingControl(bool setLocation, bool setSize, System.Drawing.Rectangle cellBounds, System.Drawing.Rectangle cellClip, DataGridViewCellStyle cellStyle, bool singleVerticalBorderAdded, bool singleHorizontalBorderAdded, bool isFirstDisplayedColumn, bool isFirstDisplayedRow)
{
    cellBounds = new System.Drawing.Rectangle(cellBounds.X, cellBounds.Y, cellBounds.Width + 16, cellBounds.Height);
    cellClip = new System.Drawing.Rectangle(cellClip.X, cellClip.Y, cellClip.Width + 16, cellClip.Height);
    base.PositionEditingControl(true, true, cellBounds, cellClip, cellStyle, singleVerticalBorderAdded, singleHorizontalBorderAdded, isFirstDisplayedColumn, isFirstDisplayedRow);
}
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900