示例#1
0
        private ModelData GetModelData(DataGridViewRow row)
        {
            var data = new ModelData();

            for (int i = 0; i < row.Cells.Count; i++)
            {
                var property = typeof(ModelData).GetProperty(itemView.Columns[i].Name);

                if (property.Name.ToLower().Contains("icon"))
                {
                }
                else
                {
                    property.SetValue(data, row.Cells[i].Value);
                }
            }

            return(data);
        }
示例#2
0
        public static void ParseAndAddItem(string name, List <ModelData> data)
        {
            string[] info = name.Split(' ');

            //If item has data

            int hasData = HasData(name, data);

            if (hasData == -1)
            {
                ModelData newdata = new ModelData();
                newdata.Name = name;

                modelData.Add(newdata);
            }
            else
            {
                modelData.Add(data[hasData]);
            }
        }
示例#3
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);
        }