Ejemplo n.º 1
0
        public Form1()
        {
            InitializeComponent();

            Controller.priceList = itemView;

            var properties = ModelData.GetProperties(false);

            foreach (var prop in properties)
            {
                Controller.priceList.Columns.Add(Controller.CreateColumm(prop.Name, prop.PropertyType));
            }


            Controller.GetPriceList();

            display.Show();
        }
Ejemplo n.º 2
0
        private static DataGridViewRow AddRow(ModelData data)
        {
            var row = new DataGridViewRow();

            var properties = ModelData.GetProperties(false);

            foreach (var prop in properties)
            {
                if (prop.PropertyType.IsEnum)
                {
                    DataGridViewComboBoxCell cell = new DataGridViewComboBoxCell();
                    cell.ValueType  = typeof(ModelData.PriceMode);
                    cell.DataSource = Enum.GetValues(typeof(ModelData.PriceMode));
                    cell.Value      = typeof(ModelData).GetProperty(prop.Name).GetValue(data, null);
                    row.Cells.Add(cell);
                }
                else if (prop.Name.ToLower().Contains("icon"))
                {
                    //Create Image column
                    DataGridViewImageCell cell = new DataGridViewImageCell();

                    cell.ValueType = typeof(Image);
                    //cell.Value = typeof(ModelData).GetProperty(prop.Name).GetValue(data, null);

                    row.Cells.Add(cell);
                }
                else
                {
                    DataGridViewTextBoxCell cell = new DataGridViewTextBoxCell();
                    var property = typeof(ModelData).GetProperty(prop.Name);
                    cell.ValueType = property.PropertyType;
                    cell.Value     = property.GetValue(data, null);
                    row.Cells.Add(cell);
                }
            }

            return(row);
        }