Ejemplo n.º 1
0
        public WindowPlan()
        {
            InitializeComponent();
            products = ((from e in kisEntites.Products select e) as IListSource).GetList() as IBindingList;
            listViewProducts.DataContext = products;

        }
        /// <summary>
        /// Constructor for OperationResultDialog Form.
        /// </summary>
        /// <param name="resultsGridDataSource">Data source for error list.</param>
        public OperationResultDialog(IBindingList resultsGridDataSource = null)
        {
            InitializeComponent();
            // Apply context menu for DataGridView.
            new DataGridViewColumnSelectorMenu(resultsGridView);

            resultsGridView.DataSource = resultsGridDataSource;
        }
Ejemplo n.º 3
0
 public Form1()
 {
     if(isSongRegex==null)
         isSongRegex = new Regex(@".*\.mp3$");
     InitializeComponent();
     songs = new BindingList<Song>();
     dataGridView1.DataSource = songs;
 }
Ejemplo n.º 4
0
        public void Initialise(List<DataGridViewColumn> columns, IBindingList items)
        {
            foreach (DataGridViewColumn column in columns)
            {
                grdItems.Columns.Add(column);
            }

            PopulateList(items);
        }
 public FilterBindingList(IBindingList sourceList, PropertyDescriptor filterProperty)
 {
     Tracer.WriteLine("FilterBindingList.FilterBindingList");
     Debug.Assert(sourceList != null);
     Debug.Assert(filterProperty != null);
     this.sourceList = sourceList;
     this.filterProperty = filterProperty;
     this.begin = 0;
     this.end = this.sourceList.Count;
     ListChangedEventManager.AddListener(this.sourceList, this);
 }
Ejemplo n.º 6
0
        public SortList(IList list)
        {
            this.m_List = list;

            if (m_List is IBindingList)
            {
                m_BindingList = m_List as IBindingList;
                m_SupportBinding = true;
                m_BindingList.ListChanged += new ListChangedEventHandler(m_BindingList_ListChanged);
            }
        }
        //------------------------------------------------------
        //
        //  Constructors
        //
        //------------------------------------------------------

        #region Constructors

        /// <summary>
        /// Constructor
        /// </summary>
        /// <param name="list">Underlying IBindingList</param>
        public BindingListCollectionView(IBindingList list)
            : base(list)
        {
            InternalList = list;
            _blv = list as IBindingListView;
            _isDataView = SystemDataHelper.IsDataView(list);

            SubscribeToChanges();

            _group = new CollectionViewGroupRoot(this);
            _group.GroupDescriptionChanged += new EventHandler(OnGroupDescriptionChanged);
            ((INotifyCollectionChanged)_group).CollectionChanged += new NotifyCollectionChangedEventHandler(OnGroupChanged);
            ((INotifyCollectionChanged)_group.GroupDescriptions).CollectionChanged += new NotifyCollectionChangedEventHandler(OnGroupByChanged);
        }
Ejemplo n.º 8
0
 public void UpdateData(IBindingList source)
 {
     if (employeesGrid.DataSource == null)
         employeesGrid.DataSource = source;
     else
     {
         employeesGridView.RefreshData();
         try
         {
             for (int rowHandle = 0; rowHandle < employeesGridView.DataRowCount; rowHandle++)
             {
                 employeesGridView.RefreshDetailExpandButton(rowHandle);
             }
         }
         catch (Exception e)
         {
         }
     }
 }
Ejemplo n.º 9
0
 /// <summary>
 /// Constructs a <see cref="ReorderableGalleryComponent"/> with the specified data source, automatically adding the actions of
 /// <see cref="GalleryToolExtensionPoint"/>s at the specified action sites.
 /// </summary>
 /// <param name="dataSource">An <see cref="IBindingList"/> of <see cref="IGalleryItem"/>s.</param>
 /// <param name="toolbarSite">The site for toolbar actions.</param>
 /// <param name="contextMenuSite">The site for context menu actions.</param>
 public ReorderableGalleryComponent(IBindingList dataSource, string toolbarSite, string contextMenuSite)
     : base(dataSource, toolbarSite, contextMenuSite)
 {
 }
Ejemplo n.º 10
0
 private void BindToControllers()
 {
     this.Projects = this.XTMF.ProjectController.Projects;
 }
Ejemplo n.º 11
0
 private void Wire(IBindingList styles)
 {
     styles.ListChanged += styles_ListChanged;
 }
Ejemplo n.º 12
0
		/// <summary>
		/// Constructs a <see cref="ReorderableGalleryComponent"/> with the specified data source, automatically adding the actions of
		/// <see cref="GalleryToolExtensionPoint"/>s at the specified action sites.
		/// </summary>
		/// <param name="dataSource">An <see cref="IBindingList"/> of <see cref="IGalleryItem"/>s.</param>
		/// <param name="toolbarSite">The site for toolbar actions.</param>
		/// <param name="contextMenuSite">The site for context menu actions.</param>
		public ReorderableGalleryComponent(IBindingList dataSource, string toolbarSite, string contextMenuSite)
			: base(dataSource, toolbarSite, contextMenuSite) {}
Ejemplo n.º 13
0
        public static void PrintShipmentOrder(IBindingList shipmentList, XPObjectSpace os)
        {
            //XafReport report = ReportHelper.GetReport("Shipment");
            //report.DataSource = shipmentList;
            //report.ShowPreview();

            ReportHelper.ShowSingleReport("Shipment", shipmentList, os);
        }
Ejemplo n.º 14
0
 public WindowPlan()
 {
     InitializeComponent();
     products = ((from e in kisEntites.Products select e) as IListSource).GetList() as IBindingList;
     listViewProducts.DataContext = products;
 }
Ejemplo n.º 15
0
        /// <summary>
        /// Return the object associated with (collection, cvs, type).
        /// If this is the first reference to this view, add it to the tables.
        /// </summary>
        /// <exception cref="ArgumentException">
        /// Thrown when the collectionViewType does not implement ICollectionView
        /// or does not have a constructor that accepts the type of collection.
        /// Also thrown when the named collection view already exists and is
        /// not the specified collectionViewType.
        /// </exception>
        internal ViewRecord GetViewRecord(object collection, CollectionViewSource cvs, Type collectionViewType, bool createView, Func <object, object> GetSourceItem)
        {
            // Order of precendence in acquiring the View:
            // 0) If  collection is already a CollectionView, return it.
            // 1) If the CollectionView for this collection has been cached, then
            //    return the cached instance.
            // 2) If a CollectionView derived type has been passed in collectionViewType
            //    create an instance of that Type
            // 3) If the collection is an ICollectionViewFactory use ICVF.CreateView()
            //    from the collection
            // 4) If the collection is an IListSource call GetList() and perform 5),
            //    etc. on the returned list
            // 5) If the collection is an IBindingList return a new BindingListCollectionView
            // 6) If the collection is an IList return a new ListCollectionView
            // 7) If the collection is an IEnumerable, return a new CollectionView
            //    (it uses the ListEnumerable wrapper)
            // 8) return null
            // An IListSource must share the view with its underlying list.

            // if the view already exists, just return it
            // Also, return null if it doesn't exist and we're called in "lazy" mode
            ViewRecord viewRecord = GetExistingView(collection, cvs, collectionViewType, GetSourceItem);

            if (viewRecord != null || !createView)
            {
                return(viewRecord);
            }

            // If the collection is an IListSource, it uses the same view as its
            // underlying list.
            IListSource ils     = collection as IListSource;
            IList       ilsList = null;

            if (ils != null)
            {
                ilsList    = ils.GetList();
                viewRecord = GetExistingView(ilsList, cvs, collectionViewType, GetSourceItem);

                if (viewRecord != null)
                {
                    return(CacheView(collection, cvs, (CollectionView)viewRecord.View, viewRecord));
                }
            }

            // Create a new view
            ICollectionView icv = collection as ICollectionView;

            if (icv != null)
            {
                icv = new CollectionViewProxy(icv);
            }
            else if (collectionViewType == null)
            {
                // Caller didn't specify a type for the view.
                ICollectionViewFactory icvf = collection as ICollectionViewFactory;
                if (icvf != null)
                {
                    // collection is a view factory - call its factory method
                    icv = icvf.CreateView();
                }
                else
                {
                    // collection is not a factory - create an appropriate view
                    IList il = (ilsList != null) ? ilsList : collection as IList;
                    if (il != null)
                    {
                        // create a view on an IList or IBindingList
                        IBindingList ibl = il as IBindingList;
                        if (ibl != null)
                        {
                            icv = new BindingListCollectionView(ibl);
                        }
                        else
                        {
                            icv = new ListCollectionView(il);
                        }
                    }
                    else
                    {
                        // collection is not IList, wrap it
                        IEnumerable ie = collection as IEnumerable;
                        if (ie != null)
                        {
                            icv = new EnumerableCollectionView(ie);
                        }
                    }
                }
            }
            else
            {
                // caller specified a type for the view.  Try to honor it.
                if (!typeof(ICollectionView).IsAssignableFrom(collectionViewType))
                {
                    throw new ArgumentException(SR.Get(SRID.CollectionView_WrongType, collectionViewType.Name));
                }

                // if collection is IListSource, get its list first (bug 1023903)
                object arg = (ilsList != null) ? ilsList : collection;

                try
                {
                    icv = Activator.CreateInstance(collectionViewType,
                                                   System.Reflection.BindingFlags.CreateInstance, null,
                                                   new object[1] {
                        arg
                    }, null) as ICollectionView;
                }
                catch (MissingMethodException e)
                {
                    throw new ArgumentException(SR.Get(SRID.CollectionView_ViewTypeInsufficient,
                                                       collectionViewType.Name, collection.GetType()), e);
                }
            }

            // if we got a view, add it to the tables
            if (icv != null)
            {
                // if the view doesn't derive from CollectionView, create a proxy that does
                CollectionView cv = icv as CollectionView;
                if (cv == null)
                {
                    cv = new CollectionViewProxy(icv);
                }

                if (ilsList != null)    // IListSource's list shares the same view
                {
                    viewRecord = CacheView(ilsList, cvs, cv, null);
                }

                viewRecord = CacheView(collection, cvs, cv, viewRecord);

                // raise the event for a new view
                BindingOperations.OnCollectionViewRegistering(cv);
            }

            return(viewRecord);
        }
Ejemplo n.º 16
0
    public static object GetValueByCoordinates(this IBindingList list, int x, int y)
    {
        object o = list[x];

        return(GetProperty(o, y).GetValue(o));
    }
Ejemplo n.º 17
0
		private void OnDataSourceChanged(object sender, EventArgs e)
		{
			this.DataSource = _component.DataSource;
		}
Ejemplo n.º 18
0
 /// <summary>
 /// Constructs a <see cref="ReorderableGalleryComponent"/> with the specified data source and without any tool actions.
 /// </summary>
 /// <param name="dataSource">An <see cref="IBindingList"/> of <see cref="IGalleryItem"/>s.</param>
 public ReorderableGalleryComponent(IBindingList dataSource) : base(dataSource)
 {
 }
 public NHServerModeSourceAdderRemover(Object serverModeSource, NHObjectSpace objectSpace, Type objectType)
 {
     this.serverModeSource = serverModeSource;
     this.objectSpace = objectSpace;
     this.objectType = objectType;
     listServer = serverModeSource as IListServer;
     listServerHints = serverModeSource as IListServerHints;
     bindingList = serverModeSource as IBindingList;
     typedList = serverModeSource as ITypedList;
     dxCloneable = serverModeSource as IDXCloneable;
     addedObjects = new List<Object>();
     addedObjectsDictionary = new Dictionary<Object, Byte>();
     removedObjectsDictionary = new Dictionary<Object, Byte>();
     bindingList.ListChanged += new ListChangedEventHandler(bindingList_ListChanged);
     ITypeInfo typeInfo = objectSpace.TypesInfo.FindTypeInfo(objectType);
     propertyDescriptorCollection = new XafPropertyDescriptorCollection(typeInfo);
     foreach (IMemberInfo memberInfo in NHObjectSpace.GetDefaultDisplayableMembers(typeInfo))
     {
         propertyDescriptorCollection.CreatePropertyDescriptor(memberInfo, memberInfo.Name);
     }
 }
Ejemplo n.º 20
0
 public IList GetList()
 {
     return(bindingList ?? (bindingList = this.ToBindingList()));
 }
Ejemplo n.º 21
0
        // return true if the list is a DataView
        internal static bool IsDataView(IBindingList list)
        {
            SystemDataExtensionMethods extensions = AssemblyHelper.ExtensionsForSystemData();

            return((extensions != null) ? extensions.IsDataView(list) : false);
        }
Ejemplo n.º 22
0
 public BindingList(IBindingList source, Func <PropertyDescriptor, PropertyDescriptor> propertyMapper) : base(source, propertyMapper)
 {
     this.source = source;
 }
 IList IListSource.GetList()
 {
     return(_bindingList ?? (_bindingList = new BindingList <T>()));
 }
Ejemplo n.º 24
0
 public void ShowView(IBindingList mensagens, TipoProcesso tipoProcesso)
 {
     SetDataBinding(mensagens);
     ShowDialog();
 }
Ejemplo n.º 25
0
         public BindingListAdapter(IBindingList bindingList) {
            Assumption.NotNull(bindingList);

            _bindingList = bindingList;
            _bindingList.ListChanged += new ListChangedEventHandler(_onListChanged);
         }
Ejemplo n.º 26
0
 public static void SetDataSource(this DataGridView dgv_table_view, IBindingList tableContentList)
 {
     dgv_table_view.DataSource = new BindingSource(tableContentList, null);
 }
Ejemplo n.º 27
0
 public DeleteRowCommand(DataGridView dataGridView, IBindingList collection) : base(dataGridView, collection)
 {
     Text = @"Delete";
 }
Ejemplo n.º 28
0
 public FilterBindingListAdapter(IBindingList bindingList)
 {
     this.bindingList = bindingList;
     DoFilter();
 }
Ejemplo n.º 29
0
 private void HookBindingListChanged(IBindingList newContext)
 {
   if (newContext != null)
     newContext.ListChanged += DataObject_ListChanged;
 }
Ejemplo n.º 30
0
 public void setDataSource_Create(IBindingList bindList)
 {
     dgvCreationTasks.DataSource = new BindingSource(bindList, null);
 }
 IList IListSource.GetList()
 {
     return(_bindingList ?? (_bindingList = this.ToBindingList()));
 }
        // Token: 0x060076F8 RID: 30456 RVA: 0x0021FCC8 File Offset: 0x0021DEC8
        internal ViewRecord GetViewRecord(object collection, CollectionViewSource cvs, Type collectionViewType, bool createView, Func <object, object> GetSourceItem)
        {
            ViewRecord viewRecord = this.GetExistingView(collection, cvs, collectionViewType, GetSourceItem);

            if (viewRecord != null || !createView)
            {
                return(viewRecord);
            }
            IListSource listSource = collection as IListSource;
            IList       list       = null;

            if (listSource != null)
            {
                list       = listSource.GetList();
                viewRecord = this.GetExistingView(list, cvs, collectionViewType, GetSourceItem);
                if (viewRecord != null)
                {
                    return(this.CacheView(collection, cvs, (CollectionView)viewRecord.View, viewRecord));
                }
            }
            ICollectionView collectionView = collection as ICollectionView;

            if (collectionView != null)
            {
                collectionView = new CollectionViewProxy(collectionView);
            }
            else if (collectionViewType == null)
            {
                ICollectionViewFactory collectionViewFactory = collection as ICollectionViewFactory;
                if (collectionViewFactory != null)
                {
                    collectionView = collectionViewFactory.CreateView();
                }
                else
                {
                    IList list2 = (list != null) ? list : (collection as IList);
                    if (list2 != null)
                    {
                        IBindingList bindingList = list2 as IBindingList;
                        if (bindingList != null)
                        {
                            collectionView = new BindingListCollectionView(bindingList);
                        }
                        else
                        {
                            collectionView = new ListCollectionView(list2);
                        }
                    }
                    else
                    {
                        IEnumerable enumerable = collection as IEnumerable;
                        if (enumerable != null)
                        {
                            collectionView = new EnumerableCollectionView(enumerable);
                        }
                    }
                }
            }
            else
            {
                if (!typeof(ICollectionView).IsAssignableFrom(collectionViewType))
                {
                    throw new ArgumentException(SR.Get("CollectionView_WrongType", new object[]
                    {
                        collectionViewType.Name
                    }));
                }
                object obj = (list != null) ? list : collection;
                try
                {
                    collectionView = (Activator.CreateInstance(collectionViewType, BindingFlags.CreateInstance, null, new object[]
                    {
                        obj
                    }, null) as ICollectionView);
                }
                catch (MissingMethodException innerException)
                {
                    throw new ArgumentException(SR.Get("CollectionView_ViewTypeInsufficient", new object[]
                    {
                        collectionViewType.Name,
                        collection.GetType()
                    }), innerException);
                }
            }
            if (collectionView != null)
            {
                CollectionView collectionView2 = collectionView as CollectionView;
                if (collectionView2 == null)
                {
                    collectionView2 = new CollectionViewProxy(collectionView);
                }
                if (list != null)
                {
                    viewRecord = this.CacheView(list, cvs, collectionView2, null);
                }
                viewRecord = this.CacheView(collection, cvs, collectionView2, viewRecord);
                BindingOperations.OnCollectionViewRegistering(collectionView2);
            }
            return(viewRecord);
        }
Ejemplo n.º 33
0
 private void MoveToLeft(IBindingList objs)
 {
     LeftSource.AddRange(objs);
     RightSource.RemoveRange(objs);
 }
Ejemplo n.º 34
0
 public static IChangeTrackableCollection <T> CastToIChangeTrackableCollection <T>(this IBindingList target) where T : class
 {
     return((IChangeTrackableCollection <T>)target);
 }
Ejemplo n.º 35
0
 private void ConnectBindingList(IBindingList list)
 {
     if (list != null)
     {
         list.ListChanged += new ListChangedEventHandler(BindingListChanged);
     }
 }
 /// <summary>
 ///     Returns an <see cref="IBindingList" /> implementation that stays in sync with
 ///     this <see cref="ObservableHashSet{T}" />. The returned list is cached on this object
 ///     such that the same list is returned each time this method is called.
 /// </summary>
 /// <returns>
 ///     An <see cref="IBindingList" /> in sync with the ObservableHashSet.
 /// </returns>
 IList IListSource.GetList() => _bindingList ?? (_bindingList = ToBindingList());
Ejemplo n.º 37
0
        //=====================================================================
        /// <summary>
        /// We still need to override this even if there are no bound controls.  It's also the place to hook up
        /// event handlers if creating such things as footer totals, etc.
        /// </summary>
        protected override void Bind()
        {
            // The demo uses a data set so we'll get a reference to the table through the list manager
            CurrencyManager cm = this.TemplateParent.ListManager;
            DataTable newSource = ((DataView)cm.List).Table;

            // Hook up the events on the data source to keep the total current
            if(newSource != tblItems)
            {
                // Disconnect from the old source if necessary
                if(tblItems != null)
                {
                    bl.ListChanged -= DataSource_ListChanged;
                    tblItems.RowChanged -= DataSource_RowChgDel;
                    tblItems.RowDeleted -= DataSource_RowChgDel;
                }

                tblItems = newSource;

                if(tblItems != null)
                {
                    // For the total, we'll sum it whenever a row is added, changed, or deleted
                    bl = (IBindingList)cm.List;

                    bl.ListChanged += DataSource_ListChanged;
                    tblItems.RowChanged += DataSource_RowChgDel;
                    tblItems.RowDeleted += DataSource_RowChgDel;

                    // Show the initial total
                    lblTotal.Text = tblItems.Compute("Sum(SumValue)", null).ToString();
                }
                else
                    lblTotal.Text = null;
            }
        }
Ejemplo n.º 38
0
 public static EventMonitor MonitorListChanged(this IBindingList bindingList)
 {
     return(new EventMonitor <ListChangedEventHandler>(bindingList, nameof(IBindingList.ListChanged), action => (_, __) => action()));
 }
Ejemplo n.º 39
0
        void LoadAddressBook(IBindingList target)
        {
            target.Clear();

            using (System.Data.SQLite.SQLiteDataReader reader = DataBase.Instance.ExecuteReader("SELECT * FROM AddressBook"))
            {
                while (reader.Read())
                {
                    reader.GetValue(0);
                    Company com = new Company(
                        reader.GetInt32(0),
                        reader.IsDBNull(1) ? string.Empty : reader.GetString(1),
                        reader.IsDBNull(2) ? string.Empty : reader.GetString(2),
                        reader.IsDBNull(3) ? string.Empty : reader.GetString(3),
                        reader.IsDBNull(4) ? string.Empty : reader.GetString(4),
                        reader.IsDBNull(5) ? string.Empty : reader.GetString(5),
                        reader.IsDBNull(6) ? string.Empty : reader.GetString(6),
                        reader.IsDBNull(7) ? string.Empty : reader.GetString(7),
                        reader.IsDBNull(8) ? string.Empty : reader.GetString(8),
                        reader.IsDBNull(9) ? string.Empty : reader.GetString(9),
                        reader.IsDBNull(10) ? string.Empty : reader.GetString(10),
                        reader.GetInt32(11));
                    target.Add(com);
                }
            }
        }
Ejemplo n.º 40
0
        /// <summary> 将表格中的数据粘贴到DataGridView控件中(通过先添加全部行,再为添加的行赋值的方式) </summary>
        /// <param name="startRow">粘贴的起始单元格的行位置</param>
        /// <param name="startCol">粘贴的起始单元格的列位置</param>
        /// <remarks>DataGridView表格的索引:行号:表头为-1,第一行为0,列号:表示行编号的列为-1,第一个数据列的列号为0.
        /// DataGridView.Rows.Count与DataGridView.Columns.Count均只计算数据区域,而不包含表头与列头。总行数包括最后一行空数据行。</remarks>
        private void PasteFromTable(int startRow, int startCol)
        {
            string pastTest = Clipboard.GetText();

            if (string.IsNullOrEmpty(pastTest))
            {
                return;
            }

            // excel中是以"空格"和"换行"来当做字段和行,所以用"\r\n"来分隔,即"回车+换行"
            string[] lines = pastTest.Split(new char[] { '\r', '\n' }, StringSplitOptions.RemoveEmptyEntries);

            int writeRowsCount = lines.Length;                //要写入多少行数据
            int writeColsCount = lines[0].Split('\t').Length; //要写入的每一行数据中有多少列
                                                              //
            int endRow = startRow + writeRowsCount - 1;       // 要修改的最后一行的行号

            int rowsToAdd = endRow + 2 - this.Rows.Count;     // 说明要额外添加这么多行才能放置要粘贴进来的数据

            if (rowsToAdd > 0)
            {
                if (DataSource is IBindingList)
                {
                    IBindingList ds = (IBindingList)this.DataSource;

                    // 对于 DataSource 绑定到 IBindingList 时,不能直接对DataGridView添加行,而是通过对于绑定的 IBindingList 进行添加来实现的。
                    // 因为 IBindingList 中每一个新添加的元素都要符合绑定的类的构造形式。
                    if (startRow == Rows.Count - 1)
                    {
                        // 当DataGridView的最后一行(AddNew的那一行)被选中时,执行BindingList.AddNew方法会出现报错。
                        // 所以这里进行判断,并且当其被选中时就先取消这一行的选择。
                        CurrentCell = null;
                    }

                    for (int i = 0; i < rowsToAdd; i++)
                    {
                        // BindingList.AddNew方法会触发其 AddingNew 事件,用户必须手动在此事件中定义要实例化的初始变量。
                        ds.AddNew();
                    }

                    CurrentCell = Rows[startRow].Cells[startCol];
                }
                else
                {  // 直接添加数据行
                    this.Rows.Add(rowsToAdd);
                }
            }
            int endCol = 0; // 要修改的最后面的那一列的列号

            endCol = startCol + writeColsCount <= this.Columns.Count
                ? startCol + writeColsCount - 1
                : this.Columns.Count - 1;


            //  每一列的要进行检测的数据类型
            Type tp;

            Type[] checkedTypes = new Type[endCol - startCol + 1];

            for (int c = startCol; c <= endCol; c++)
            {
                tp = Columns[c].ValueType;
                // 如果某列的ValueType为Nullable<>的话,则要对其所指定的泛型进行检测,
                // 因为在为Rows[r].Cells[c].Value赋值时,字符"1.2"不能转换为float,而会被转换为null,
                // 但实际上1.2是一个合法的float值。所以这里要通过Convert.ChangeType来进行显式检验。
                checkedTypes[c - startCol] = Utils.GetNullableGenericArgurment(tp) ?? tp;
            }

            // 当前操作的单元格的坐标
            int    rowIndex = 0, colIndex = 0;
            object value;

            try
            {
                // 数据赋值与检测
                string   strline = "";
                string[] strs    = null;
                for (rowIndex = startRow; rowIndex <= endRow; rowIndex++)
                {
                    // 一条记录中的数据
                    strline = lines[rowIndex - startRow];
                    strs    = strline.Split('\t'); //在每一行的单元格间,作为单元格的分隔的字符为"\t",即水平换行符

                    for (colIndex = startCol; colIndex <= endCol; colIndex++)
                    {
                        // Convert.ChangeType 用来检查字符所对应的值是否可以转换为对应字段列的数据类型,如果不能转换,则会报错。
                        value = !string.IsNullOrEmpty(strs[colIndex - startCol])
                            ? Convert.ChangeType(strs[colIndex - startCol], checkedTypes[colIndex - startCol])
                            : null;

                        // 在修改单元格数据时,即使添加的数据不符合此列字段的数据格式,也不会报错,而是会直接取消对于此单元格的赋值,转而继续进行下一个单元格的赋值操作。
                        this.Rows[rowIndex].Cells[colIndex].Value = value;

                        SetSelectedCellCore(colIndex, rowIndex, true);  // 选中此单元格
                    }
                }
            }
            catch (Exception ex)
            {
                DebugUtils.ShowDebugCatch(ex, $"粘贴数据出错,出错的单元格为第 {rowIndex + 1} 行,第 {colIndex + 1} 列)");
            }
        }
Ejemplo n.º 41
0
 private void Unwire(IBindingList styles)
 {
     styles.ListChanged -= styles_ListChanged;
 }
Ejemplo n.º 42
0
        //=====================================================================

        /// <summary>
        /// This is used to update the change policy based on the owning data list or data navigator
        /// </summary>
        /// <param name="canAdd">If true and the data source permits it, allow additions</param>
        /// <param name="canEdit">If true and the data source permits it, allow edits</param>
        /// <param name="canDelete">If true and the data source permits it, allow deletes</param>
        internal void UpdatePolicy(bool canAdd, bool canEdit, bool canDelete)
        {
            bool listCanAdd, listCanEdit, listCanDelete, listChangeNotify, oldAdd = this.AllowAdditions,
                 oldEdit = this.AllowEdits, oldDelete = this.AllowDeletes;

            CurrencyManager listManager = (dataList != null) ? dataList.ListManager : dataNav.ListManager;

            if (listManager == null)
            {
                this.AllowAdditions = canAdd;
                this.AllowEdits     = canEdit;
                this.AllowDeletes   = canDelete;
            }
            else
            {
                IBindingList bl = (listManager.List as IBindingList);

                if (bl != null)
                {
                    listCanAdd       = bl.AllowNew;
                    listCanEdit      = bl.AllowEdit;
                    listCanDelete    = bl.AllowRemove;
                    listChangeNotify = bl.SupportsChangeNotification;
                }
                else
                {
                    listCanAdd       = listCanDelete = (!listManager.List.IsReadOnly && !listManager.List.IsFixedSize);
                    listCanEdit      = !listManager.List.IsReadOnly;
                    listChangeNotify = false;
                }

                this.AllowAdditions = (canAdd && listCanAdd && listChangeNotify);
                this.AllowEdits     = (canEdit && listCanEdit);
                this.AllowDeletes   = (canDelete && listCanDelete && listChangeNotify);
            }

            // If the change policy was modified, raise the ChangePolicyModified event on the owner
            if (dataList != null)
            {
                if (this.AllowAdditions != oldAdd || this.AllowEdits != oldEdit || this.AllowDeletes != oldDelete)
                {
                    dataList.OnChangePolicyModified(new ChangePolicyEventArgs(this.AllowAdditions,
                                                                              this.AllowEdits, this.AllowDeletes));
                }
                else
                {
                    // Enable or disable Add and Delete based on the policy
                    dataList.btnAdd.Enabled    = (this.AllowAdditions && listManager != null);
                    dataList.btnDelete.Enabled = (this.AllowDeletes && listManager != null &&
                                                  listManager.Count > 0);
                }
            }
            else
            if (this.AllowAdditions != oldAdd || this.AllowEdits != oldEdit || this.AllowDeletes != oldDelete)
            {
                dataNav.OnChangePolicyModified(new ChangePolicyEventArgs(this.AllowAdditions, this.AllowEdits,
                                                                         this.AllowDeletes));
            }
            else
            {
                // Enable or disable Add and Delete based on the policy
                dataNav.btnAdd.Enabled    = (this.AllowAdditions && listManager != null);
                dataNav.btnDelete.Enabled = (this.AllowDeletes && listManager != null && listManager.Count > 0);
            }
        }
Ejemplo n.º 43
0
 private void MoveToRight(IBindingList objs)
 {
     RightSource.AddRange(objs);
     LeftSource.RemoveRange(objs);
 }
Ejemplo n.º 44
0
        // Attaches the control to a data source.
        private void SetDataBinding()
        {
            // The BindingContext is initially null - in general we will not
            // obtain a BindingContext until we are attached to our parent
            // control. (OnParentBindingContextChanged will be called when
            // that happens, so this method will run again. This means it's
            // OK to ignore this call when we don't yet have a BindingContext.)
            if (BindingContext != null)
            {
                // Obtain the CurrencyManager and (if available) IBindingList
                // for the current data source.
                CurrencyManager currencyManager = null;
                IBindingList    bindingList     = null;

                if (DataSource != null)
                {
                    currencyManager = (CurrencyManager)
                                      BindingContext[DataSource, DataMember];
                    if (currencyManager != null)
                    {
                        bindingList = currencyManager.List as IBindingList;
                    }
                }

                // Now see if anything has changed since we last bound to a source.

                bool reloadMetaData = false;
                bool reloadItems    = false;
                if (currencyManager != m_currencyManager)
                {
                    // We have a new CurrencyManager. If we were previously
                    // using another CurrencyManager (i.e. if this is not the
                    // first time we've seen one), we'll have some event
                    // handlers attached to the old one, so first we must
                    // detach those.
                    if (m_currencyManager != null)
                    {
                        currencyManager.MetaDataChanged -=
                            new EventHandler(CurrencyManager_MetaDataChanged);
                        //currencyManager.PositionChanged -=
                        //    new EventHandler(CurrencyManager_PositionChanged);                // Commented by Enrique Pérez: Dec 2, 2018
                        currencyManager.ItemChanged -=
                            new ItemChangedEventHandler(CurrencyManager_ItemChanged);
                    }

                    // Now hook up event handlers to the new CurrencyManager.
                    // This enables us to detect when the currently selected
                    // row changes. It also lets us find out more major changes
                    // such as binding to a different list object (this happens
                    // when binding to related views - each time the currently
                    // selected row in a parent changes, the child list object
                    // is replaced with a new object), or even changes in the
                    // set of properties.
                    m_currencyManager = currencyManager;
                    if (currencyManager != null)
                    {
                        reloadMetaData = true;
                        reloadItems    = true;
                        currencyManager.MetaDataChanged +=
                            new EventHandler(CurrencyManager_MetaDataChanged);
                        //currencyManager.PositionChanged +=
                        //new EventHandler(CurrencyManager_PositionChanged);                 // Commented by Enrique Pérez: Dec 2, 2018
                        currencyManager.ItemChanged +=
                            new ItemChangedEventHandler(CurrencyManager_ItemChanged);
                    }
                }

                if (bindingList != m_bindingList)
                {
                    // The IBindingList has changed. If we were previously
                    // bound to an IBindingList, detach the event handler.
                    if (m_bindingList != null)
                    {
                        m_bindingList.ListChanged -=
                            new ListChangedEventHandler(BindingList_ListChanged);
                    }

                    // Now hook up a handler to the new IBindingList - this
                    // will notify us of any changes in the list. (This is
                    // more detailed than the CurrencyManager ItemChanged
                    // event. However, we need both, because the only way we
                    // know when the list is replaced completely is when the
                    // CurrencyManager raises the ItemChanged event.)
                    m_bindingList = bindingList;
                    if (bindingList != null)
                    {
                        reloadItems              = true;
                        bindingList.ListChanged +=
                            new ListChangedEventHandler(BindingList_ListChanged);
                    }
                }

                // If a change occurred that means the set of properties may
                // have changed, reload these.
                if (reloadMetaData)
                {
                    LoadColumnsFromSource();
                }

                // If a change occurred that means the set of items to be
                // shown in the list may have changed, reload those.
                if (reloadItems)
                {
                    LoadItemsFromSource();
                }
            }
        }
Ejemplo n.º 45
0
 /// <summary>
 /// датасурс для грида сотрудников
 /// </summary>
 /// <param name="source"></param>
 void IMainView.SetDataSourceForEmployeeGrid(IBindingList source)
 {
     employeeControl.UpdateData(source);
 }
Ejemplo n.º 46
0
        public void PopulateList(IBindingList items)
        {
            grdItems.DataSource = items;

            CheckSetButtons();
        }
Ejemplo n.º 47
0
		public Dashboard(WeSay.UI.IProject project, IBindingList records)
		{
			_records = records;
			_project = project;
		}
Ejemplo n.º 48
0
		// Attaches the control to a data source.
		private void SetDataBinding(bool reload)
		{
			// The BindingContext is initially null - in general we will not
			// obtain a BindingContext until we are attached to our parent
			// control. (OnParentBindingContextChanged will be called when
			// that happens, so this method will run again. This means it's
			// OK to ignore this call when we don't yet have a BindingContext.)
			if (BindingContext != null)
			{

				// Obtain the CurrencyManager and (if available) IBindingList
				// for the current data source.
				CurrencyManager currencyManager = null;
				IBindingList bindingList = null;

				if (DataSource != null)
				{
					currencyManager = (CurrencyManager)
						BindingContext[DataSource, null];
					if (currencyManager != null)
					{
						bindingList = currencyManager.List as IBindingList;
					}
				}

				// Now see if anything has changed since we last bound to a source.

				bool reloadMetaData = false;
				bool reloadItems = false;
				if (currencyManager != m_currencyManager)
				{
					// We have a new CurrencyManager. If we were previously
					// using another CurrencyManager (i.e. if this is not the
					// first time we've seen one), we'll have some event
					// handlers attached to the old one, so first we must
					// detach those.
					if (m_currencyManager != null)
					{
						//currencyManager.MetaDataChanged -=
						//    new EventHandler(currencyManager_MetaDataChanged);
						currencyManager.PositionChanged -=
							new EventHandler(currencyManager_PositionChanged);
						currencyManager.ItemChanged -=
							new ItemChangedEventHandler(currencyManager_ItemChanged);
					}

					// Now hook up event handlers to the new CurrencyManager.
					// This enables us to detect when the currently selected
					// row changes. It also lets us find out more major changes
					// such as binding to a different list object (this happens
					// when binding to related views - each time the currently
					// selected row in a parent changes, the child list object
					// is replaced with a new object), or even changes in the
					// set of properties.
					m_currencyManager = currencyManager;
					if (currencyManager != null)
					{
						reloadMetaData = true;
						reloadItems = true;
						// currencyManager.MetaDataChanged +=
						//    new EventHandler(currencyManager_MetaDataChanged);
						currencyManager.PositionChanged +=
							new EventHandler(currencyManager_PositionChanged);
						currencyManager.ItemChanged +=
							new ItemChangedEventHandler(currencyManager_ItemChanged);
					}
				}

				if (bindingList != m_bindingList)
				{
					// The IBindingList has changed. If we were previously
					// bound to an IBindingList, detach the event handler.
					if (m_bindingList != null)
					{
						m_bindingList.ListChanged -=
							new ListChangedEventHandler(bindingList_ListChanged);
					}

					// Now hook up a handler to the new IBindingList - this
					// will notify us of any changes in the list. (This is
					// more detailed than the CurrencyManager ItemChanged
					// event. However, we need both, because the only way we
					// know when the list is replaced completely is when the
					// CurrencyManager raises the ItemChanged event.)
					m_bindingList = bindingList;
					if (bindingList != null)
					{
						reloadItems = true;
						bindingList.ListChanged +=
							new ListChangedEventHandler(bindingList_ListChanged);
					}
				}
				

				// If a change occurred that means the set of items to be
				// shown in the list may have changed, reload those.
				if ((reloadItems) || (reload) && (m_currencyManager != null))
				{
					m_properties = m_currencyManager.GetItemProperties();
					LoadItemsFromSource();
				}
			}

		}
Ejemplo n.º 49
0
 public CutRowsCommand(DataGridView gridView, IBindingList collection) : base(gridView, collection)
 {
 }
Ejemplo n.º 50
0
 public FullBindingList()
 {
     _list                       = new BindingList <T>();
     _list.ListChanged          += _list_ListChanged;
     this.RaiseListChangedEvents = true;
 }
Ejemplo n.º 51
0
		//data source has changed
		protected override void OnDataSourceChanged(EventArgs e)
		{
			//remove event handler
			if(thebindinglist != null)
			{
				thebindinglist.ListChanged-= new ListChangedEventHandler(ComboBoxEx_ListChanged);
				//reset our handle to the bound data
				thebindinglist = null;
			}

			//get the underlying ibindinglist (if there is one)
			if(this.DataSource is IListSource)
			{
				IList thelist = ((IListSource)this.DataSource).GetList();
				if(thelist is IBindingList)
				{
					thebindinglist = (IBindingList)thelist;
				}
			}
			else if(this.DataSource is IBindingList)
			{
				thebindinglist = (IBindingList)this.DataSource;
			}
			
			if(thebindinglist != null)
			{
				//hook up event for data changed
				thebindinglist.ListChanged+=new ListChangedEventHandler(ComboBoxEx_ListChanged);
			}
			
			base.OnDataSourceChanged (e);
		}
Ejemplo n.º 52
0
 public SimpleComposerAdapterGalleryComponent(IBindingList dataSource, string subActionSite) : base(dataSource, "studyComposer-toolbar", "studyComposer-context")
 {
 }
 public static void RemoveListener( IBindingList source, IWeakEventListener listener )
 {
   CurrentManager.ProtectedRemoveListener( source, listener );
 }
        //public IList IListSource.GetList()
        //{
        //    return _bindingList ?? (_bindingList = this.ToBindingList());
        //}

        public IList GetList()
        {
            return(_bindingList ?? (_bindingList = new BindingList <T>()));
        }
Ejemplo n.º 55
0
		//		protected override void OnSelectedIndexChanged(EventArgs e)
		//		{
		//			base.OnSelectedIndexChanged (e);
		//
		//			// Did this originate from us, or was this caused by the
		//			// CurrencyManager in the first place. If we're sure it was us,
		//			// and there is actually a selected item (this event is also raised
		//			// when transitioning to the 'no items selected' state), and we
		//			// definitely do have a CurrencyManager (i.e. we are actually bound
		//			// to a data source), then we notify the CurrencyManager.
		//
		//			if (!m_changingIndex && this.SelectedIndex > 0 && m_currencyManager != null)
		//			{
		//				m_currencyManager.Position = this.SelectedIndex;
		//			}
		//		}
		
		private void currencyManager_ItemChanged(object sender, ItemChangedEventArgs e)
		{
			// An index of -1 seems to be the indication that lots has
			// changed. (I've not found where it says this in the
			// documentation - I got this information from a comment in Mark
			// Boulter's code.) So we always reload all items from the
			// source when this happens.
			if (e.Index == -1)
			{
				// ...but before we reload all items from source, we also look
				// to see if the list we're supposed to bind to has changed
				// since last time, and if it has, reattach our event handlers.

				if (!m_bindingList.Equals(m_currencyManager.List))
				{
					m_bindingList.ListChanged -=
						new ListChangedEventHandler(bindingList_ListChanged);
					m_bindingList = m_currencyManager.List as IBindingList;
					if (m_bindingList != null)
					{
						m_bindingList.ListChanged +=
							new ListChangedEventHandler(bindingList_ListChanged);
					}
				}
				LoadItemsFromSource();                
			}
		}
Ejemplo n.º 56
0
 public NewRowCommand(DataGridView dataGridView, IBindingList collection) : base(dataGridView, collection)
 {
     Text = @"New";
 }
Ejemplo n.º 57
0
 private void UnHookBindingListChanged(IBindingList oldContext)
 {
   if (oldContext != null)
     oldContext.ListChanged -= DataObject_ListChanged;
 }
Ejemplo n.º 58
0
 public void SetCollectionViewModel(IBindingList bindingList)
 {
     this.model = bindingList;
 }
 // return true if the list is a DataView
 internal static bool IsDataView(IBindingList list)
 {
     SystemDataExtensionMethods extensions = AssemblyHelper.ExtensionsForSystemData();
     return (extensions != null) ? extensions.IsDataView(list) : false;
 }
Ejemplo n.º 60
0
 /// <summary>
 /// Unwire binding list.
 /// </summary>
 /// <param name="item">The item.</param>
 private void UnWireBindingList(IBindingList item)
 {
     item.ListChanged -= new ListChangedEventHandler(item_ListChanged);
 }