Exemplo n.º 1
0
        public static BindingSource GetBindingSource(DataColumn column)
        {
            if (column == null)
            {
                return(null);
            }

            BindingSource bs = TableUtil.GetProperty(column, BINDINGSOURCE) as BindingSource;

            if (bs == null)
            {
                lock (column)
                {
                    bs = TableUtil.GetProperty(column, BINDINGSOURCE) as BindingSource;
                    if (bs == null)
                    {
                        bs            = new BindingSource();
                        bs.DataSource = column.Table.AsDataView();
                        bs.DataMember = column.ColumnName;
                        TableUtil.SetProperty(column, BINDINGSOURCE, bs);
                    }
                }
            }
            return(bs);
        }
Exemplo n.º 2
0
        public static BindingSource GetBindingSource(DataTable table)
        {
            if (table == null)
            {
                return(null);
            }

            BindingSource bs = TableUtil.GetProperty(table, BINDINGSOURCE) as BindingSource;

            if (bs == null)
            {
                lock (table)
                {
                    bs = TableUtil.GetProperty(table, BINDINGSOURCE) as BindingSource;
                    if (bs == null)
                    {
                        bs            = new BindingSource();
                        bs.DataSource = table.AsDataView();
                        TableUtil.SetProperty(table, BINDINGSOURCE, bs);
                    }
                }
            }
            return(bs);
        }