开发者

How to make a DataGridView column no-entry in VS2010/C#

I have开发者_开发问答 a DataGridView which allows me to enter name/value pairs. The names are pre-defined, so the user just needs to enter a value. I have made the name (the first) column read-only so it can't be changed - that's great, but it can still be selected, and indeed, is by default when the form is displayed. Is it possible to make this (a) column no-entry, so it's not possible to select it? I think I've gone through all options in VS2010, and I've searched on Google but I can't even find someone else asking about it.

Many thanks

Ludwig


you can handle the selection by using the cell enter event and triggering an TAB press, this would mean that the particular is not selectable and instead the focus moves on to the next desired cell.

private void dataGridView1_CellEnter(object sender, DataGridViewCellEventArgs e)
        {
            if (e.ColumnIndex == dataGridView1.Columns["NoSelect"].Index)
            { SendKeys.Send("{TAB}"); }
        }
0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜