开发者

Custom DataGridViewCell, second click to edit

I've implemented my own DataGridViewCell with a colour picker / opacity cell.

I want the cell to behave as per t开发者_如何转开发he standard controls, such as DataGridViewTextCell which you first click to select, then click again to edit.

The obvious thing was to call BeginEdit from with in the Click handler if Selected is true, but I my cell state is always Selected by the time the click handler is invoke. I can't see how to differentiate the state of the control between the first and second clicks.

Any help is very much appreciated.

Thanks Andy


I've done it by handling MouseDown

protected override void OnMouseDown(DataGridViewCellMouseEventArgs e)
{
    _nextClickBeginEdit = Selected;
    base.OnMouseDown(e);
}

protected override void OnClick(DataGridViewCellEventArgs e)
{
    base.OnClick(e);
    if (_nextClickBeginEdit)
    {
        DataGridView.BeginEdit(false);
    }
}
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜