Example #1
0
        private void ResultsetGrid_Load(object sender, EventArgs e)
        {
            this.tableName = TableName;

            try
            {
                this.dataGridView1.AutoGenerateColumns = true;
                this.dataGridView1.DataError          += new DataGridViewDataErrorEventHandler(dataGridView1_DataError);
                imageContext.Items.Add("Import Image", null, new EventHandler(ImportImage));
                imageContext.Items.Add("Export Image", null, new EventHandler(ExportImage));
                imageContext.Items.Add("Delete Image", null, new EventHandler(DeleteImage));

                LoadData(SqlText);

                this.dataGridView1.ReadOnly = ReadOnly;
                if (this.ReadOnlyColumns != null)
                {
                    foreach (int x in ReadOnlyColumns)
                    {
                        this.dataGridView1.Columns[x].ReadOnly = true;
                        this.dataGridView1.Columns[x].DefaultCellStyle.ForeColor = SystemColors.GrayText;
                    }
                }
                if (Properties.Settings.Default.MultiLineTextEntry)
                {
                    foreach (DataGridViewColumn col in dataGridView1.Columns)
                    {
                        if (col is DataGridViewTextBoxColumn)
                        {
                            col.DefaultCellStyle.WrapMode = DataGridViewTriState.True;
                        }
                    }
                    this.dataGridView1.AutoSizeRowsMode = DataGridViewAutoSizeRowsMode.AllCells;
                }

                this.bindingNavigatorAddNewItem.Enabled = !ReadOnly;
                this.bindingNavigatorDeleteItem.Enabled = !ReadOnly;
                this.toolStripButton1.Enabled           = !ReadOnly;

                this.dataGridView1.ClipboardCopyMode       = DataGridViewClipboardCopyMode.EnableAlwaysIncludeHeaderText;
                this.dataGridView1.AllowUserToOrderColumns = true;
                this.dataGridView1.MultiSelect             = false;
                //if (Properties.Settings.Default.ShowNullValuesAsNULL)
                //{
                //    this.dataGridView1.DefaultCellStyle.NullValue = "NULL";
                //}
                this.dataGridView1.KeyDown += new KeyEventHandler(dataGridView1_KeyDown);
                //this.dataGridView1.CellContentClick += new DataGridViewCellEventHandler(dataGridView1_CellContentClick);
                dgs = new DataGridViewSearch(this.dataGridView1);
                if (ReadOnly)
                {
                    this.dataGridView1.DefaultCellStyle.ForeColor = SystemColors.GrayText;
                    EnvDteHelper.ShowError("No primary keys on table, data is read-only");
                }
            }
            catch (Exception ex)
            {
                Helpers.DataConnectionHelper.SendError(ex, DatabaseInfo.DatabaseType, false);
            }
        }
Example #2
0
        private void ResultsetGrid_Load(object sender, EventArgs e)
        {
            this.tableName = TableName;

            try
            {
                this.dataGridView1.AutoGenerateColumns = true;
                this.dataGridView1.DataError += new DataGridViewDataErrorEventHandler(dataGridView1_DataError);
                imageContext.Items.Add("Import Image", null, new EventHandler(ImportImage));
                imageContext.Items.Add("Export Image", null, new EventHandler(ExportImage));
                imageContext.Items.Add("Delete Image", null, new EventHandler(DeleteImage));

                LoadData(SqlText);
                
                this.dataGridView1.ReadOnly = ReadOnly;
                if (this.ReadOnlyColumns != null)
                {
                    foreach (int x in ReadOnlyColumns)
                    {
                        this.dataGridView1.Columns[x].ReadOnly = true;
                        this.dataGridView1.Columns[x].DefaultCellStyle.ForeColor = SystemColors.GrayText;
                    }
                }
                if (Properties.Settings.Default.MultiLineTextEntry)
                {
                    foreach (DataGridViewColumn col in dataGridView1.Columns)
                    {
                        if (col is DataGridViewTextBoxColumn)
                        {
                            col.DefaultCellStyle.WrapMode = DataGridViewTriState.True;
                        }
                    }
                    this.dataGridView1.AutoSizeRowsMode = DataGridViewAutoSizeRowsMode.AllCells;
                }

                this.bindingNavigatorAddNewItem.Enabled = !ReadOnly;
                this.bindingNavigatorDeleteItem.Enabled = !ReadOnly;
                this.toolStripButton1.Enabled = !ReadOnly;

                this.dataGridView1.ClipboardCopyMode = DataGridViewClipboardCopyMode.EnableAlwaysIncludeHeaderText;
                this.dataGridView1.AllowUserToOrderColumns = true;
                this.dataGridView1.MultiSelect = false;
                //if (Properties.Settings.Default.ShowNullValuesAsNULL)
                //{
                //    this.dataGridView1.DefaultCellStyle.NullValue = "NULL";
                //}
                this.dataGridView1.KeyDown += new KeyEventHandler(dataGridView1_KeyDown);
                //this.dataGridView1.CellContentClick += new DataGridViewCellEventHandler(dataGridView1_CellContentClick);
                dgs = new DataGridViewSearch(this.dataGridView1);
                if (ReadOnly)
                {
                    this.dataGridView1.DefaultCellStyle.ForeColor = SystemColors.GrayText;
                    EnvDTEHelper.ShowError("No primary keys on table, data is read-only");
                }
            }
            catch (Exception ex)
            {
                Helpers.DataConnectionHelper.SendError(ex, DatabaseInfo.DatabaseType, false);
            }
        }
Example #3
0
        private void ResultsetGrid_Load(object sender, EventArgs e)
        {
            this.tableName = TableName;

            try
            {
                this.dataGridView1.AutoGenerateColumns = true;
                this.dataGridView1.DataError += new DataGridViewDataErrorEventHandler(dataGridView1_DataError);
                imageContext.Items.Add("Import Image", null, new EventHandler(ImportImage));
                imageContext.Items.Add("Export Image", null, new EventHandler(ExportImage));
                imageContext.Items.Add("Delete Image", null, new EventHandler(DeleteImage));                
                LoadData();
                
                this.dataGridView1.ReadOnly = ReadOnly;
                if (this.ReadOnlyColumns != null)
                {
                    foreach (int x in ReadOnlyColumns)
                    {
                        this.dataGridView1.Columns[x].ReadOnly = true;
                        this.dataGridView1.Columns[x].DefaultCellStyle.ForeColor = SystemColors.GrayText;
                    }
                }
                if (Properties.Settings.Default.MultiLineTextEntry)
                {
                    foreach (DataGridViewColumn col in dataGridView1.Columns)
                    {
                        if (col is DataGridViewTextBoxColumn)
                        {
                            col.DefaultCellStyle.WrapMode = DataGridViewTriState.True;
                        }
                    }
                }
                this.dataGridView1.AutoSizeRowsMode = DataGridViewAutoSizeRowsMode.AllCells;

                this.bindingNavigatorAddNewItem.Enabled = !ReadOnly;
                this.bindingNavigatorDeleteItem.Enabled = !ReadOnly;
                this.toolStripButton1.Enabled = !ReadOnly;

                this.dataGridView1.ClipboardCopyMode = DataGridViewClipboardCopyMode.EnableAlwaysIncludeHeaderText;
                this.dataGridView1.AllowUserToOrderColumns = true;
                this.dataGridView1.MultiSelect = false;
                
                this.dataGridView1.KeyDown += new KeyEventHandler(dataGridView1_KeyDown);
                dgs = new DataGridViewSearch(this.dataGridView1);
            }
            catch (Exception ex)
            {
                MessageBox.Show(Helpers.DataConnectionHelper.ShowErrors(ex));
            }
        }
Example #4
0
        private void ResultsetGrid_Load(object sender, EventArgs e)
        {
            this.tableName = TableName;

            try
            {
                this.dataGridView1.AutoGenerateColumns = true;
                this.dataGridView1.DataError          += new DataGridViewDataErrorEventHandler(dataGridView1_DataError);
                imageContext.Items.Add("Import Image", null, new EventHandler(ImportImage));
                imageContext.Items.Add("Export Image", null, new EventHandler(ExportImage));
                imageContext.Items.Add("Delete Image", null, new EventHandler(DeleteImage));
                LoadData();

                this.dataGridView1.ReadOnly = ReadOnly;
                if (this.ReadOnlyColumns != null)
                {
                    foreach (int x in ReadOnlyColumns)
                    {
                        this.dataGridView1.Columns[x].ReadOnly = true;
                        this.dataGridView1.Columns[x].DefaultCellStyle.ForeColor = SystemColors.GrayText;
                    }
                }
                if (Properties.Settings.Default.MultiLineTextEntry)
                {
                    foreach (DataGridViewColumn col in dataGridView1.Columns)
                    {
                        if (col is DataGridViewTextBoxColumn)
                        {
                            col.DefaultCellStyle.WrapMode = DataGridViewTriState.True;
                        }
                    }
                }
                this.dataGridView1.AutoSizeRowsMode = DataGridViewAutoSizeRowsMode.AllCells;

                this.bindingNavigatorAddNewItem.Enabled = !ReadOnly;
                this.bindingNavigatorDeleteItem.Enabled = !ReadOnly;
                this.toolStripButton1.Enabled           = !ReadOnly;

                this.dataGridView1.ClipboardCopyMode       = DataGridViewClipboardCopyMode.EnableAlwaysIncludeHeaderText;
                this.dataGridView1.AllowUserToOrderColumns = true;
                this.dataGridView1.MultiSelect             = false;

                this.dataGridView1.KeyDown += new KeyEventHandler(dataGridView1_KeyDown);
                dgs = new DataGridViewSearch(this.dataGridView1);
            }
            catch (Exception ex)
            {
                MessageBox.Show(Helpers.DataConnectionHelper.ShowErrors(ex));
            }
        }