示例#1
0
 public object ValueFomatted(object source, DataCellType dataFormater)
 {
     if (DataSouceType != null && ForzenColumn != null)
     {
         List <string> s = new List <string>();
         IList         DataSourceValue = GetList(DataSouceType) as IList;
         foreach (DataGridViewRow row in this.Rows)
         {
             if (this[ForzenColumn.Index, row.Index].Value != null)
             {
                 object Entity = System.Activator.CreateInstance(DataSouceType);
                 foreach (DataGridViewColumn column in this.Columns)
                 {
                     string DataPropertyName = column.DataPropertyName;
                     if (!string.IsNullOrEmpty(DataPropertyName))
                     {
                         PropertyInfo propertyInfo = Entity.GetType().GetProperty(DataPropertyName);
                         if (propertyInfo != null)
                         {
                             if (propertyInfo.PropertyType == typeof(int))
                             {
                                 propertyInfo.SetValue(Entity, TryParse.StrToInt(this[column.Index, row.Index].Value), null);
                             }
                             else if (propertyInfo.PropertyType == typeof(decimal))
                             {
                                 propertyInfo.SetValue(Entity, TryParse.StrToDecimal(this[column.Index, row.Index].Value), null);
                             }
                             else
                             {
                                 propertyInfo.SetValue(Entity, this[column.Index, row.Index].Value, null);
                             }
                         }
                     }
                 }
                 DataSourceValue.Add(Entity);
             }
             else
             {
                 break;
             }
         }
         return(DataSourceValue);
     }
     return(null);
 }