Which winforms manages / is suitable for binding to collection <> collection of custom objects?

What management approach can I use to quickly visually edit the List collection.
I have a memory in mind.

My requirements are basically:

  • provide facilities in my winform, allow adding / viewing / editing ConfigFileDTO information list, BUT
  • Only the "PATH" field of ConfigFileDTO should be available to the user, so usage can:
    • add a new PATH list to the list,
    • remove PATH, and therefore remove ConfigFileDTO from the list,
    • and edit the list allowing you to change one of the PATH in the list.

My code

    private static List<ConfigFileDTO> files;

    public class ConfigFileDTO
    {
        private string filename, content_type, path;
        private int file_size;
        private DateTime updated_at;

        public ConfigFileDTO() {  }

        public int FileSize {
            get { return this.file_size;  }
            set { this.file_size = value; }
        }    
        public string ContentType {
            get { return this.content_type; }
            set { this.content_type = value; }
        }    
        public string Filename {
            get { return this.filename; }
            set { this.filename = value; }
        }    
        public DateTime UpdatedAt {
            get { return this.updated_at; }
            set { this.updated_at = value; }
        }    
        public string Path {
            get { return this.path; }
            set { this.path = value; }
        }    
    }

      

thank

+2


source share


1 answer


If you want the column to be rendered Path

, then it's usually best to just set up the column bindings (for things like DataGridView

) manually; however, you can also use things like [Browsable(false)]

(removes property from display) and [ReadOnly(true)]

(treat property as read-only even if it has a setter) to control the handling of properties (/ columns).



If you want to control how new instances are created, inherit from BindingList<T>

and override AddNewCore()

.

+2


source







All Articles