webnoob
webnoob

Reputation: 15934

Can't make DataGridView Checkbox non readonly

I have a DataGridView that I'm binding a list to:

var list = GetOrderedPlayListItems(playList.Items.Where(f => f != null).ToList());
gvPlayListItems.AutoGenerateColumns = false;
gvPlayListItems.DataSource = list;
Console.WriteLine(gvPlayListItems[3, 0].ReadOnly); //Displays TRUE

The problem I have is that my CheckBox column (column 4) is readonly. Things I've checked:

  1. The designer for the column and the gridview are both readonly false.
  2. I've checked my code and I'm not setting readonly anywhere.
  3. I've checked playList.Items and the class behind that item has public bool FullScreen {get;set;} so nothing private and my DataPropertyName is FullScreen.

I've tried setting it to not readonly in bindcomplete but that didn't help.

Any ideas as I'm a little stumped and currently, can't click the checkbox.

Upvotes: 0

Views: 1153

Answers (2)

webnoob
webnoob

Reputation: 15934

I've found the issue for this. The column wasn't read only, the grid wasn't read only but after looking at my Designer.cs file and looking for ReadOnly = true I saw the DataGridView.RowTemplate.ReadOnly flag was set to true ...

I mean, how many read only's do we need :)

Anyway, that sorted it.

Upvotes: 0

Byren Higgin
Byren Higgin

Reputation: 562

what about gvPlayListItems[2, 0].ReadOnly? you mention the 3rd column but [3, 0] is the 4th column. Just a first glance look at the issue

Upvotes: 1

Related Questions