Esempio n. 1
0
        // event declaration
        //public event LinkClickedHandler LinkClick;

        private void ResultsetGrid_Load(object sender, EventArgs e)
        {
            try
            {
                dataGridView1.AutoGenerateColumns = true;
                dataGridView1.DataError          += dataGridView1_DataError;
                dataGridView1.ShowRowErrors       = true;
                _imageContext.Items.Add("Import Image", null, ImportImage);
                _imageContext.Items.Add("Export Image", null, ExportImage);
                _imageContext.Items.Add("Delete Image", null, DeleteImage);

                LoadData(SqlText);

                dataGridView1.ReadOnly = ReadOnly;
                if (ReadOnlyColumns != null)
                {
                    foreach (int x in ReadOnlyColumns)
                    {
                        dataGridView1.Columns[x].ReadOnly = true;
                        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;
                        }
                    }
                    dataGridView1.AutoSizeRowsMode = DataGridViewAutoSizeRowsMode.AllCells;
                }

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

                dataGridView1.ClipboardCopyMode       = DataGridViewClipboardCopyMode.EnableAlwaysIncludeHeaderText;
                dataGridView1.AllowUserToOrderColumns = true;
                dataGridView1.MultiSelect             = false;
                //if (Properties.Settings.Default.ShowNullValuesAsNULL)
                //{
                //    dataGridView1.DefaultCellStyle.NullValue = "NULL";
                //}
                dataGridView1.KeyDown += dataGridView1_KeyDown;
                //dataGridView1.CellContentClick += new DataGridViewCellEventHandler(dataGridView1_CellContentClick);
                _dgs = new DataGridViewSearch(dataGridView1);
                if (ReadOnly)
                {
                    dataGridView1.DefaultCellStyle.ForeColor = SystemColors.GrayText;
                    EnvDteHelper.ShowError("No primary keys on table, data is read-only");
                }
            }
            catch (Exception ex)
            {
                DataConnectionHelper.SendError(ex, DatabaseInfo.DatabaseType, false);
            }
        }
Esempio n. 2
0
        // event declaration
        //public event LinkClickedHandler LinkClick;

        private void ResultsetGrid_Load(object sender, EventArgs e)
        {
            try
            {
                dataGridView1.AutoGenerateColumns = true;
                dataGridView1.DataError          += dataGridView1_DataError;
                dataGridView1.ShowRowErrors       = true;
                _imageContext.Items.Add("Import Image", null, ImportImage);
                _imageContext.Items.Add("Export Image", null, ExportImage);
                _imageContext.Items.Add("Delete Image", null, DeleteImage);

                LoadData(_sqlText);

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

                dataGridView1.ClipboardCopyMode       = DataGridViewClipboardCopyMode.EnableAlwaysIncludeHeaderText;
                dataGridView1.AllowUserToOrderColumns = true;
                dataGridView1.MultiSelect             = false;
                //if (Properties.Settings.Default.ShowNullValuesAsNULL)
                //{
                //    dataGridView1.DefaultCellStyle.NullValue = "NULL";
                //}
                dataGridView1.KeyDown += dataGridView1_KeyDown;
                //dataGridView1.CellContentClick += new DataGridViewCellEventHandler(dataGridView1_CellContentClick);
                _dgs = new DataGridViewSearch(dataGridView1);
                if (ReadOnly)
                {
                    dataGridView1.DefaultCellStyle.ForeColor = SystemColors.GrayText;
                    MessageBox.Show("No primary keys on table, data is read-only");
                }
            }
            catch (Exception ex)
            {
                AddSqlPanel();
                _pnlSql.SqlText = ex.ToString();
            }
        }