Esempio n. 1
0
        /// <summary>
        /// This will bind the table to the grid, using the first column for the checked boxes,
        /// and sorting the rest of the grid by ASortColumn.
        /// If you want to use the event DataColumnChanged, first assign the property DataColumnChanged before calling this procedure.
        ///
        /// </summary>
        /// <returns>void</returns>
        public void DataBindGrid(System.Data.DataTable ATable,
                                 String ASortColumn,
                                 String ACheckedColumn,
                                 List <String> AKeyColumns,
                                 bool AAllowNew,
                                 bool AAllowEdit,
                                 bool AAllowDelete)
        {
            FDataTable            = ATable;
            FDataView             = FDataTable.DefaultView;
            FDataView.Sort        = ASortColumn;
            FCheckedColumn        = ACheckedColumn;
            FKeyColumns           = new List <String>(AKeyColumns);
            FDataView.AllowNew    = AAllowNew;
            FDataView.AllowEdit   = AAllowEdit;
            FDataView.AllowDelete = AAllowDelete;

            // DataBind the DataGrid
            DataSource = new DevAge.ComponentModel.BoundDataView(FDataView);
            this.SelectRowWithoutFocus(1);

            // Hook event that allows popping up a question whether to check the CheckBox
            if (!DesignMode)
            {
                FDataTable.ColumnChanged += MyDataColumnChangedEventHandler;
            }
        }
Esempio n. 2
0
 public Grid(DataSet ds)
 {
     this.bd=new DevAge.ComponentModel.BoundDataView(ds.Tables[0].DefaultView);
     this.bd.mDataView.RowFilter = "";
     InitializeComponent();
     this.ShowDialog(Parent);
 }
Esempio n. 3
0
        private void frmSample41_Load(object sender, System.EventArgs e)
        {
            //Read Data From xml
            DataSet ds = new DataSet();

            System.IO.Stream stream = System.Reflection.Assembly.GetExecutingAssembly().GetManifestResourceStream("WindowsFormsSample.GridSamples.SampleData2.xml");
            ds.ReadXml(stream);
            mView             = ds.Tables[0].DefaultView;
            mView.AllowDelete = false;
            mView.AllowNew    = false;

            dataGrid.FixedColumns = 1;
            dataGrid.Selection.EnableMultiSelection = true;

            DevAge.ComponentModel.IBoundList bd = new DevAge.ComponentModel.BoundDataView(mView);

            //Create default columns
            CreateColumns(bd);

            dataGrid.DataSource = bd;

            dataGrid.AutoSizeCells();

            dataGrid.Selection.SelectionChanged += new SourceGrid.RangeRegionChangedEventHandler(Selection_SelectionChanged);
        }
Esempio n. 4
0
        private static void TestBindingDataView()
        {
            //Create a sample DataSet
            System.Data.DataSet   ds    = new System.Data.DataSet();
            System.Data.DataTable table = ds.Tables.Add("Table1");
            table.Columns.Add("Col1", typeof(string));
            table.Columns.Add("Col2", typeof(double));
            table.Rows.Add("Value 1", 59.7);
            table.Rows.Add("Value 2", 59.9);


            System.Data.DataView dView = table.DefaultView;

            DevAge.ComponentModel.BoundDataView bd = new DevAge.ComponentModel.BoundDataView(dView);

            bd.ListChanged += delegate(object sender, System.ComponentModel.ListChangedEventArgs e)
            {
                System.Diagnostics.Debug.WriteLine("ListChanged " + dView.Count);
            };

            System.ComponentModel.PropertyDescriptorCollection props = bd.GetItemProperties();

            int r;

            r = bd.BeginAddNew();

            bd.SetEditValue(props[0], "Pluto");
            bd.SetEditValue(props[1], 394);

            bd.EndEdit(true);


            r = bd.BeginAddNew();

            bd.SetEditValue(props[0], "Peter");
            bd.SetEditValue(props[1], 89);

            bd.EndEdit(false);


            bd.BeginEdit(0);
            bd.SetEditValue(props[0], "Test");
            bd.EndEdit(true);

            bd.BeginEdit(0);
            bd.SetEditValue(props[0], "Test 2");
            bd.EndEdit(false);
        }
Esempio n. 5
0
        private static void TestBindingDataView()
        {
            //Create a sample DataSet
            System.Data.DataSet ds = new System.Data.DataSet();
            System.Data.DataTable table = ds.Tables.Add("Table1");
            table.Columns.Add("Col1", typeof(string));
            table.Columns.Add("Col2", typeof(double));
            table.Rows.Add("Value 1", 59.7);
            table.Rows.Add("Value 2", 59.9);


            System.Data.DataView dView = table.DefaultView;

            DevAge.ComponentModel.BoundDataView bd = new DevAge.ComponentModel.BoundDataView(dView);

            bd.ListChanged += delegate(object sender, System.ComponentModel.ListChangedEventArgs e) 
                        {
                            System.Diagnostics.Debug.WriteLine("ListChanged " + dView.Count);
                        };

            System.ComponentModel.PropertyDescriptorCollection props = bd.GetItemProperties();

            int r;

            r = bd.BeginAddNew();

            bd.SetEditValue(props[0], "Pluto");
            bd.SetEditValue(props[1], 394);

            bd.EndEdit(true);

            
            r = bd.BeginAddNew();

            bd.SetEditValue(props[0], "Peter");
            bd.SetEditValue(props[1], 89);

            bd.EndEdit(false);


            bd.BeginEdit(0);
            bd.SetEditValue(props[0], "Test");
            bd.EndEdit(true);

            bd.BeginEdit(0);
            bd.SetEditValue(props[0], "Test 2");
            bd.EndEdit(false);
        }
Esempio n. 6
0
        private void btLoad_Click(object sender, System.EventArgs e)
        {
            try
            {
                System.Data.DataSet dataset = new System.Data.DataSet();
                using (System.Data.Odbc.OdbcDataAdapter adapter = new System.Data.Odbc.OdbcDataAdapter(txtSqlQuery.Text, txtConnectionString.Text))
                {
                    adapter.Fill(dataset);
                }

                //Debug Trace
                dataset.Tables[0].RowDeleted    += new System.Data.DataRowChangeEventHandler(frmSample9_RowDeleted);
                dataset.Tables[0].RowChanged    += new System.Data.DataRowChangeEventHandler(frmSample9_RowChanged);
                dataset.Tables[0].ColumnChanged += new System.Data.DataColumnChangeEventHandler(frmSample9_ColumnChanged);

                lbRowsNumber.Text = "Rows: " + dataset.Tables[0].Rows.Count;

                dataGrid.FixedColumns = 1;
                dataGrid.FixedRows    = 1;
                dataGrid.Columns.Clear();

                DevAge.ComponentModel.BoundDataView bd = new DevAge.ComponentModel.BoundDataView(dataset.Tables[0].DefaultView);
                bd.AllowNew    = chkAllowNew.Checked;
                bd.AllowEdit   = chkEdit.Checked;
                bd.AllowDelete = chkAllowDelete.Checked;

                dataGrid.DataSource = bd;
                dataGrid.Columns[0].AutoSizeMode = SourceGrid.AutoSizeMode.MinimumSize;
                dataGrid.Columns[0].Width        = 20;

                dataGrid.Columns.AutoSizeView();
            }
            catch (Exception err)
            {
                DevAge.Windows.Forms.ErrorDialog.Show(this, err, "Error loading dataset");
            }
        }
Esempio n. 7
0
        private void frmSample29_Load(object sender, System.EventArgs e)
        {
            //Read Data From xml
            DataSet ds = new DataSet();

            ds.ReadXml(System.Reflection.Assembly.GetExecutingAssembly().GetManifestResourceStream("WindowsFormsSample.GridSamples.SampleData2.xml"));
            mView = ds.Tables[0].DefaultView;


            dataGrid.FixedRows    = 1;
            dataGrid.FixedColumns = 1;

            //Header row
            dataGrid.Columns.Insert(0, SourceGrid.DataGridColumn.CreateRowHeader(dataGrid));

            DevAge.ComponentModel.IBoundList bindList = new DevAge.ComponentModel.BoundDataView(mView);

            //Create default columns
            CreateColumns(dataGrid.Columns, bindList);

            dataGrid.DataSource = bindList;

            dataGrid.AutoSizeCells();
        }
Esempio n. 8
0
        private void InitializeAccountDataGrid()
        {
            #region InitializeAccountDataGrid

            this.accountDataTable = new System.Data.DataTable();
            this.accountDataTable.Columns.Add(Account_Column_Order, typeof(int));
            this.accountDataTable.Columns.Add(Account_Column_AccountId, typeof(int));
            this.accountDataTable.Columns.Add(Account_Column_TopMost, typeof(short));
            this.accountDataTable.Columns.Add(Account_Column_Name, typeof(string));
            this.accountDataTable.Columns.Add(Account_Column_LoginName, typeof(string));
            this.accountDataTable.Columns.Add(Account_Column_Secret, typeof(SecretRank));
            this.accountDataTable.Columns.Add(Account_Column_Email, typeof(string));
            this.accountDataTable.Columns.Add(Account_Column_Mobile, typeof(string));
            this.accountDataTable.Columns.Add(Account_Column_URL, typeof(string));
            this.accountDataTable.Columns.Add(Account_Column_CreateTime, typeof(System.DateTime));
            this.accountDataTable.Columns.Add(Account_Column_UpdateTime, typeof(System.DateTime));

            this.dataGridAccount.BorderStyle    = BorderStyle.Fixed3D;
            this.dataGridAccount.BackColor      = System.Drawing.SystemColors.AppWorkspace;
            this.dataGridAccount.Font           = ApplicationDefines.DefaultDataGridCellFont;
            this.dataGridAccount.Rows.RowHeight = 30;
            this.dataGridAccount.Rows.SetHeight(0, 30);
            this.dataGridAccount.SelectionMode = SourceGrid.GridSelectionMode.Cell;
            this.dataGridAccount.Selection.EnableMultiSelection = true;
            this.dataGridAccount.ClipboardMode = SourceGrid.ClipboardMode.All;

            var tmpGridSelection = this.dataGridAccount.Selection as SourceGrid.Selection.SelectionBase;
            if (tmpGridSelection != null)
            {
                tmpGridSelection.Border    = tmpGridSelection.Border.SetColor(System.Drawing.Color.Blue);
                tmpGridSelection.BackColor = System.Drawing.Color.FromArgb(60, tmpGridSelection.BackColor);
            }

            SourceGrid.DataGridColumn tmpGridColumn;
            tmpGridColumn = this.dataGridAccount.Columns.Add(Account_Column_Order, SafePassResource.DataGridAccountColumnOrderNo, typeof(int));
            tmpGridColumn = this.dataGridAccount.Columns.Add(Account_Column_AccountId, SafePassResource.DataGridAccountColumnAccountGuid, typeof(string));
            tmpGridColumn = this.dataGridAccount.Columns.Add(Account_Column_TopMost, SafePassResource.DataGridAccountColumnTopMost, typeof(short));
            tmpGridColumn = this.dataGridAccount.Columns.Add(Account_Column_Name, SafePassResource.DataGridAccountColumnName, typeof(string));
            tmpGridColumn = this.dataGridAccount.Columns.Add(Account_Column_Secret, SafePassResource.DataGridAccountColumnSecret, typeof(SecretRank));
            tmpGridColumn = this.dataGridAccount.Columns.Add(Account_Column_LoginName, SafePassResource.DataGridAccountColumnLoginName, typeof(string));
            tmpGridColumn = this.dataGridAccount.Columns.Add(Account_Column_Mobile, SafePassResource.DataGridAccountColumnMobile, typeof(string));
            tmpGridColumn = this.dataGridAccount.Columns.Add(Account_Column_Email, SafePassResource.DataGridAccountColumnEmail, typeof(string));
            tmpGridColumn = this.dataGridAccount.Columns.Add(Account_Column_CreateTime, SafePassResource.DataGridAccountColumnCreateTime, typeof(System.DateTime));
            tmpGridColumn = this.dataGridAccount.Columns.Add(Account_Column_UpdateTime, SafePassResource.DataGridAccountColumnUpdateTime, typeof(System.DateTime));
            tmpGridColumn = this.dataGridAccount.Columns.Add(Account_Column_URL, SafePassResource.DataGridAccountColumnURL, typeof(string));

            var tmpDateTimeFormat    = ApplicationDefines.DateTimeFormat;
            var dateTimeParseFormats = new string[] { tmpDateTimeFormat };
            var tmpDateTimeStyles    = System.Globalization.DateTimeStyles.AllowInnerWhite | System.Globalization.DateTimeStyles.AllowLeadingWhite | System.Globalization.DateTimeStyles.AllowTrailingWhite | System.Globalization.DateTimeStyles.AllowWhiteSpaces;
            var tmpDateTimeEditor    = new SourceGrid.Cells.Editors.TextBoxUITypeEditor(typeof(System.DateTime));
            tmpDateTimeEditor.TypeConverter = new DevAge.ComponentModel.Converter.DateTimeTypeConverter(tmpDateTimeFormat, dateTimeParseFormats, tmpDateTimeStyles);

            var tmpDataSource = new DevAge.ComponentModel.BoundDataView(this.accountDataTable.DefaultView);
            tmpDataSource.AllowNew          = false;
            tmpDataSource.AllowSort         = true;
            this.dataGridAccount.DataSource = tmpDataSource;

            var tmpGridColor  = System.Drawing.SystemColors.ActiveBorder;
            var tmpGridBorder = new DevAge.Drawing.RectangleBorder(new DevAge.Drawing.BorderLine(tmpGridColor, 0), new DevAge.Drawing.BorderLine(tmpGridColor));

            var tmpGridLinkCellView = new SourceGrid.Cells.Views.Link();
            tmpGridLinkCellView.Font = ApplicationDefines.DefaultDataGridCellFont;

            var tmpAlignCenterCellView = new SourceGrid.Cells.Views.Cell();
            tmpAlignCenterCellView.TextAlignment = DevAge.Drawing.ContentAlignment.MiddleCenter;
            tmpAlignCenterCellView.Font          = ApplicationDefines.DefaultDataGridCellFont;

            var tmpLoginNameCellView = new SourceGrid.Cells.Views.Cell();
            tmpLoginNameCellView.Font = new System.Drawing.Font("Consolas", 10, System.Drawing.FontStyle.Regular);

            this.SecretCellRank0               = new SourceGrid.Cells.Views.Cell();
            this.SecretCellRank0.ForeColor     = System.Drawing.Color.White;
            this.SecretCellRank0.BackColor     = Program.Config.Application.Security.SecretRank.Rank0BackColor;
            this.SecretCellRank0.TextAlignment = DevAge.Drawing.ContentAlignment.MiddleCenter;
            this.SecretCellRank0.Font          = ApplicationDefines.DefaultDataGridCellFont;

            this.SecretCellRank1               = new SourceGrid.Cells.Views.Cell();
            this.SecretCellRank1.ForeColor     = System.Drawing.Color.White;
            this.SecretCellRank1.BackColor     = Program.Config.Application.Security.SecretRank.Rank1BackColor;
            this.SecretCellRank1.TextAlignment = DevAge.Drawing.ContentAlignment.MiddleCenter;
            this.SecretCellRank1.Font          = ApplicationDefines.DefaultDataGridCellFont;

            this.SecretCellRank2               = new SourceGrid.Cells.Views.Cell();
            this.SecretCellRank2.ForeColor     = System.Drawing.Color.White;
            this.SecretCellRank2.BackColor     = Program.Config.Application.Security.SecretRank.Rank2BackColor;
            this.SecretCellRank2.TextAlignment = DevAge.Drawing.ContentAlignment.MiddleCenter;
            this.SecretCellRank2.Font          = ApplicationDefines.DefaultDataGridCellFont;

            this.SecretCellRank3               = new SourceGrid.Cells.Views.Cell();
            this.SecretCellRank3.ForeColor     = System.Drawing.Color.White;
            this.SecretCellRank3.BackColor     = Program.Config.Application.Security.SecretRank.Rank3BackColor;
            this.SecretCellRank3.TextAlignment = DevAge.Drawing.ContentAlignment.MiddleCenter;
            this.SecretCellRank3.Font          = ApplicationDefines.DefaultDataGridCellFont;

            var tmpTopMostModel = new SourceGrid.Cells.Views.Cell();
            tmpTopMostModel.ImageAlignment = DevAge.Drawing.ContentAlignment.MiddleCenter;
            this.GridCellTopMost           = new SourceGrid.Cells.Cell();
            this.GridCellTopMost.View      = new SourceGrid.Cells.Views.Cell(tmpTopMostModel);
            this.GridCellTopMost.Image     = HuiruiSoft.Safe.Properties.Resources.TopMost;

            this.GridCellTopNone       = new SourceGrid.Cells.Cell();
            this.GridCellTopNone.View  = new SourceGrid.Cells.Views.Cell(tmpTopMostModel);
            this.GridCellTopNone.Image = HuiruiSoft.Safe.Properties.Resources.TopNone;

            var tmpConditionTopMost = new SourceGrid.Conditions.ConditionCell(this.GridCellTopMost);
            tmpConditionTopMost.EvaluateFunction = delegate(SourceGrid.DataGridColumn column, int gridRow, object itemRow)
            {
                var tmpDataRow = (System.Data.DataRowView)itemRow;
                return(tmpDataRow[Account_Column_TopMost] is short && (short)tmpDataRow[Account_Column_TopMost] > 0);
            };

            var tmpConditionTopNone = new SourceGrid.Conditions.ConditionCell(this.GridCellTopNone);
            tmpConditionTopNone.EvaluateFunction = delegate(SourceGrid.DataGridColumn column, int gridRow, object itemRow)
            {
                var tmpDataRow = (System.Data.DataRowView)itemRow;
                return(tmpDataRow[Account_Column_TopMost] is short && (short)tmpDataRow[Account_Column_TopMost] <= 0);
            };

            var tmpConditionRank0 = new SourceGrid.Conditions.ConditionView(this.SecretCellRank0);
            tmpConditionRank0.EvaluateFunction = delegate(SourceGrid.DataGridColumn column, int gridRow, object itemRow)
            {
                var tmpDataRow = (System.Data.DataRowView)itemRow;
                return(tmpDataRow[Account_Column_Secret] is ushort && (ushort)tmpDataRow[Account_Column_Secret] == (ushort)SecretRank.¹«¿ª);
            };

            var tmpConditionRank1 = new SourceGrid.Conditions.ConditionView(this.SecretCellRank1);
            tmpConditionRank1.EvaluateFunction = delegate(SourceGrid.DataGridColumn column, int gridRow, object itemRow)
            {
                var tmpDataRow = (System.Data.DataRowView)itemRow;
                return(tmpDataRow[Account_Column_Secret] is ushort && (ushort)tmpDataRow[Account_Column_Secret] == (ushort)SecretRank.ÃØÃÜ);
            };

            var tmpConditionRank2 = new SourceGrid.Conditions.ConditionView(this.SecretCellRank2);
            tmpConditionRank2.EvaluateFunction = delegate(SourceGrid.DataGridColumn column, int gridRow, object itemRow)
            {
                var tmpDataRow = (System.Data.DataRowView)itemRow;
                return(tmpDataRow[Account_Column_Secret] is ushort && (ushort)tmpDataRow[Account_Column_Secret] == (ushort)SecretRank.»úÃÜ);
            };

            var tmpConditionRank3 = new SourceGrid.Conditions.ConditionView(this.SecretCellRank3);
            tmpConditionRank3.EvaluateFunction = delegate(SourceGrid.DataGridColumn column, int gridRow, object itemRow)
            {
                var tmpDataRow = (System.Data.DataRowView)itemRow;
                return(tmpDataRow[Account_Column_Secret] is ushort && (ushort)tmpDataRow[Account_Column_Secret] == (ushort)SecretRank.¾øÃÜ);
            };

            for (int index = 0; index < this.dataGridAccount.Columns.Count; index++)
            {
                var tmpCurrentColumn = this.dataGridAccount.Columns[index];
                tmpCurrentColumn.HeaderCell.View.Border        = tmpGridBorder;
                tmpCurrentColumn.HeaderCell.View.TextAlignment = DevAge.Drawing.ContentAlignment.MiddleCenter;

                if (tmpCurrentColumn.DataCell.Editor != null)
                {
                    tmpCurrentColumn.DataCell.Editor.EnableEdit = false;
                }

                switch (tmpCurrentColumn.PropertyName)
                {
                case Account_Column_AccountId:
                case Account_Column_CreateTime:
                    tmpCurrentColumn.Width   = 150;
                    tmpCurrentColumn.Visible = false;
                    break;

                case Account_Column_TopMost:
                    tmpCurrentColumn.Width = 50;
                    tmpCurrentColumn.Conditions.Add(tmpConditionTopNone);
                    tmpCurrentColumn.Conditions.Add(tmpConditionTopMost);
                    break;

                case Account_Column_Order:
                    tmpCurrentColumn.Width         = 50;
                    tmpCurrentColumn.DataCell.View = tmpAlignCenterCellView;
                    break;

                case Account_Column_Name:
                    tmpCurrentColumn.Width = 175;
                    break;

                case Account_Column_Secret:
                    tmpCurrentColumn.Width = 80;
                    tmpCurrentColumn.Conditions.Add(tmpConditionRank0);
                    tmpCurrentColumn.Conditions.Add(tmpConditionRank1);
                    tmpCurrentColumn.Conditions.Add(tmpConditionRank2);
                    tmpCurrentColumn.Conditions.Add(tmpConditionRank3);
                    break;

                case Account_Column_LoginName:
                    tmpCurrentColumn.Width         = 200;
                    tmpCurrentColumn.DataCell.View = tmpLoginNameCellView;
                    break;

                case Account_Column_Mobile:
                    tmpCurrentColumn.Width         = 120;
                    tmpCurrentColumn.DataCell.View = tmpAlignCenterCellView;
                    break;

                case Account_Column_Email:
                    tmpCurrentColumn.Width = 200;
                    break;

                case Account_Column_URL:
                    tmpCurrentColumn.Width         = 270;
                    tmpCurrentColumn.DataCell.View = tmpGridLinkCellView;
                    tmpCurrentColumn.DataCell.AddController(new LinkClickController());
                    break;

                case Account_Column_UpdateTime:
                    tmpCurrentColumn.Width                      = 156;
                    tmpCurrentColumn.DataCell.Editor            = tmpDateTimeEditor;
                    tmpCurrentColumn.DataCell.Editor.EnableEdit = false;
                    tmpCurrentColumn.DataCell.View              = tmpAlignCenterCellView;
                    break;
                }
            }

            #endregion InitializeAccountDataGrid
        }
 private void UpdateDisplayedBalance()
 {
     DevAge.ComponentModel.BoundDataView dv = (DevAge.ComponentModel.BoundDataView)grdInvoices.DataSource;
     txtFilteredBalance.NumberValueDecimal = UpdateBalance(dv.DataView);
 }
Esempio n. 10
0
		private void frmSample41_Load(object sender, System.EventArgs e)
		{
			//Read Data From xml
			DataSet ds = new DataSet();
			System.IO.Stream stream = System.Reflection.Assembly.GetExecutingAssembly().GetManifestResourceStream("WindowsFormsSample.GridSamples.SampleData2.xml");
			ds.ReadXml(stream);
			mView = ds.Tables[0].DefaultView;
			mView.AllowDelete = false;
			mView.AllowNew = false;

			dataGrid.FixedColumns = 1;

            DevAge.ComponentModel.IBoundList bd = new DevAge.ComponentModel.BoundDataView(mView);

			//Create default columns
            CreateColumns(bd);

			dataGrid.DataSource = bd;

            dataGrid.AutoSizeCells();

            dataGrid.Selection.SelectionChanged += new SourceGrid.RangeRegionChangedEventHandler(Selection_SelectionChanged);
		}
Esempio n. 11
0
		private void btLoad_Click(object sender, System.EventArgs e)
		{
			try
			{

				System.Data.DataSet dataset = new System.Data.DataSet();
				using (System.Data.Odbc.OdbcDataAdapter adapter = new System.Data.Odbc.OdbcDataAdapter(txtSqlQuery.Text, txtConnectionString.Text))
				{
					adapter.Fill(dataset);
				}

				//Debug Trace
				dataset.Tables[0].RowDeleted += new System.Data.DataRowChangeEventHandler(frmSample9_RowDeleted);
				dataset.Tables[0].RowChanged += new System.Data.DataRowChangeEventHandler(frmSample9_RowChanged);
				dataset.Tables[0].ColumnChanged += new System.Data.DataColumnChangeEventHandler(frmSample9_ColumnChanged);

				lbRowsNumber.Text = "Rows: " + dataset.Tables[0].Rows.Count;

				dataGrid.FixedColumns = 1;
				dataGrid.FixedRows = 1;
				dataGrid.Columns.Clear();

                DevAge.ComponentModel.BoundDataView bd = new DevAge.ComponentModel.BoundDataView(dataset.Tables[0].DefaultView);
                bd.AllowNew = chkAllowNew.Checked;
                bd.AllowEdit = chkEdit.Checked;
                bd.AllowDelete = chkAllowDelete.Checked;

                dataGrid.DataSource = bd;
				dataGrid.Columns[0].AutoSizeMode = SourceGrid.AutoSizeMode.MinimumSize;
				dataGrid.Columns[0].Width = 20;

				dataGrid.Columns.AutoSizeView();
			}
			catch(Exception err)
			{
				DevAge.Windows.Forms.ErrorDialog.Show(this, err, "Error loading dataset");
			}
		}
Esempio n. 12
0
 private void UpdateDisplayedBalance()
 {
     DevAge.ComponentModel.BoundDataView dv = (DevAge.ComponentModel.BoundDataView)grdInvoices.DataSource;
     txtFilteredBalance.Text = UpdateBalance(dv.DataView).ToString("n2") + " " + FMainForm.LedgerCurrency;
 }
Esempio n. 13
0
        /// <summary>
        /// This will bind the table to the grid, using the first column for the checked boxes,
        /// and sorting the rest of the grid by ASortColumn.
        /// If you want to use the event DataColumnChanged, first assign the property DataColumnChanged before calling this procedure.
        ///
        /// </summary>
        /// <returns>void</returns>
        public void DataBindGrid(System.Data.DataTable ATable,
            String ASortColumn,
            String ACheckedColumn,
            List <String>AKeyColumns,
            bool AAllowNew,
            bool AAllowEdit,
            bool AAllowDelete)
        {
            FDataTable = ATable;
            FDataView = FDataTable.DefaultView;
            FDataView.Sort = ASortColumn;
            FCheckedColumn = ACheckedColumn;
            FKeyColumns = new List <String>(AKeyColumns);
            FDataView.AllowNew = AAllowNew;
            FDataView.AllowEdit = AAllowEdit;
            FDataView.AllowDelete = AAllowDelete;

            // DataBind the DataGrid
            DataSource = new DevAge.ComponentModel.BoundDataView(FDataView);
            this.SelectRowWithoutFocus(1);

            // Hook event that allows popping up a question whether to check the CheckBox
            if (!DesignMode)
            {
                FDataTable.ColumnChanged += MyDataColumnChangedEventHandler;
            }
        }
Esempio n. 14
0
 private void UpdateDisplayedBalance()
 {
     DevAge.ComponentModel.BoundDataView dv = (DevAge.ComponentModel.BoundDataView)grdResult.DataSource;
     txtFilteredBalance.Text = UpdateBalance(dv.DataView).ToString("n2") + " " + FSupplierRow.CurrencyCode;
 }
Esempio n. 15
0
		private void frmSample29_Load(object sender, System.EventArgs e)
		{
			//Read Data From xml
			DataSet ds = new DataSet();
			ds.ReadXml(System.Reflection.Assembly.GetExecutingAssembly().GetManifestResourceStream("WindowsFormsSample.GridSamples.SampleData2.xml"));
			mView = ds.Tables[0].DefaultView;


			dataGrid.FixedRows = 1;
			dataGrid.FixedColumns = 1;

			//Header row
			dataGrid.Columns.Insert(0, SourceGrid.DataGridColumn.CreateRowHeader(dataGrid));

            DevAge.ComponentModel.IBoundList bindList = new DevAge.ComponentModel.BoundDataView(mView);

			//Create default columns
            CreateColumns(dataGrid.Columns, bindList);

            dataGrid.DataSource = bindList;

            dataGrid.AutoSizeCells();
		}