Пример #1
0
 /// <summary>
 /// 移除
 /// </summary>
 /// <param name="row"></param>
 public void Remove(GridDataRow row)
 {
     if (dataSource != null)
     {
         dataSource.Remove(row);
     }
     Datas.Remove(row);
     if (object.Equals(SelectedItem, row))
     {
         selectedItem = null;
     }
 }
Пример #2
0
        /// <summary>
        /// 添加数据
        /// </summary>
        /// <param name="data"></param>
        /// <returns></returns>
        public GridDataRow AddData(object data)
        {
            if (data == null)
            {
                throw new ArgumentException("data");
            }
            if (dataSource == null)
            {
                throw new ArgumentException("dataSource");
            }
            var row = new GridDataRow()
            {
                Grid = this,
                Data = data
            };

            dataSource.Add(row);
            Datas.Add(row);
            if (SelectedItem == null)
            {
                SelectedItem = row;
            }
            else
            {
                var index = Datas.IndexOf(SelectedItem);
                if (index.Equals(-1))
                {
                    SelectedItem = row;
                }
                else
                {
                    SelectedItem = row;
                }
            }

            return(row);
        }