苯苯的博客

新随笔 联系 管理
  21 Posts :: 0 Stories :: 3 Comments :: 0 Trackbacks

2008年3月26日 #

将List<T>转换为BindingList<T>,然后设置DataGridView的DataSource为BindingList<T>!!
代码:

DataGridView.DataSource = new BindingList<T>(List<T>);

将绑定BindingList<T>的DataSource转化为List<T>,同理
代码:
List<T> modelList=new List<T>((BindingList<T>)this.DataGridView.DataSource);


说明:BindingList<T>和List<T>都有个构造函数,参数是IEnumerable<T>,既然他们俩个都是继承IEnumerable,当然能相互转换。

下面是这个构造函数的执行过程:

public List(IEnumerable<T> collection)
{
    
if (collection == null)
    
{
        ThrowHelper.ThrowArgumentNullException(ExceptionArgument.collection);
    }

    ICollection
<T> is2 = collection as ICollection<T>;
    
if (is2 != null)
    
{
        
int count = is2.Count;
        
this._items = new T[count];
        is2.CopyTo(
this._items, 0);
        
this._size = count;
    }

    
else
    
{
        
this._size = 0;
        
this._items = new T[4];
        
using (IEnumerator<T> enumerator = collection.GetEnumerator())
        
{
            
while (enumerator.MoveNext())
            
{
                
this.Add(enumerator.Current);
            }

        }

    }

}


posted @ 2008-03-26 06:50 one 阅读(441) | 评论 (3)编辑

Advantage: benefit, positive aspect, strength, 好处

Disadvantage: weakness, drawback, negative aspect, fault不利

Casual: arbitrary, unplanned, unexpected, 随意的

Effective: efficient, effectual, fruitful, productive, valid多效的

Criticize: reproach, blame, 批评

Flaw: weakness, defect 缺点

Ability; capability, power, caliber能力

Dishonest: deceptive 不诚实的

Fair: equitable, equal, impartial, 公平的

Success: achievement, feat 成功

Reason: factor, contributor, origin, 原因

Result: outcome, consequence, implication结果

Result from: arise from, originate from, be due to, thanks to, 由于,因为

Give rise to: contribute to, lead to, result in, cause, breed, create, incur导致

Disaster: catastrophe 灾难

Pollute: contaminate 污染

Poisonous: toxic 有毒的

Decrease; fall, drop, plunge, decline, step back, downward, minimize, abate下降

Increase: rise, go up, surge, grow, 上升

Growing: increasing, rising, 上升的

posted @ 2008-03-26 06:28 one 阅读(52) | 评论 (0)编辑