1

I've created a DataGridView, then binded it to the List as follows:

public struct singleFieldFrame
        {
            //text and URL frames
            private string id;
            private string text;

            public string id_p { get { return id; } }

            public string text_p { get { return text; } set { text = value; } }

            public singleFieldFrame(string frameID, string data): this()
            {
                id = frameID;
                text = data.Replace('\0', ';');
            }
        }
...
public static List<singleFieldFrame> singleFieldFrames;
...

// this struct and singleFieldFrames which is a List of singleFieldFrame reside in the public class
// dataGridView definition is inside another public class (namespace is the same)

    var bindingList1 = new BindingList<ID3v2tag.singleFieldFrame>(ID3v2tag.singleFieldFrames);
                    source1= new BindingSource(bindingList1, null);
                    dataGridView1.DataSource = source1;

My problem is that I'm unable to change any cells in the dataGridView1. When I leave editing mode,the cell value automatically resets back to previous one.

  • 1
    I could be mistaken, however from my tests, it appears the `struct` is not allowing you to change the values. Have you considered making it a “Class” instead? – JohnG Sep 19 '20 at 14:09
  • It worked! Thank you very much! P.S. I wonder why the struct is not suitable in my case... – Maxim Voloshin Sep 19 '20 at 14:17
  • 1
    I can not say for sure, take a look at this question, it may help… [Changing the value of an element in a list of structs](https://stackoverflow.com/questions/51526/changing-the-value-of-an-element-in-a-list-of-structs) – JohnG Sep 19 '20 at 14:21

0 Answers0