DevExpress Gridview eingebaut

This commit is contained in:
Christopher Meinhold 2024-08-28 14:24:15 +02:00
parent ac93a0305a
commit 2bdfa76c7e
2 changed files with 57 additions and 22 deletions

View File

@ -57,9 +57,11 @@ namespace Firmendatenbank
btnCRM = new Button();
tableLayoutPanel1 = new TableLayoutPanel();
txtStatus = new TextBox();
dataGridViewWpVersionen = new DataGridView();
gridControl1 = new DevExpress.XtraGrid.GridControl();
gridView1 = new DevExpress.XtraGrid.Views.Grid.GridView();
tableLayoutPanel1.SuspendLayout();
((System.ComponentModel.ISupportInitialize)dataGridViewWpVersionen).BeginInit();
((System.ComponentModel.ISupportInitialize)gridControl1).BeginInit();
((System.ComponentModel.ISupportInitialize)gridView1).BeginInit();
SuspendLayout();
//
// txtFirmenname
@ -277,7 +279,7 @@ namespace Firmendatenbank
tableLayoutPanel1.Controls.Add(txtFirmenname, 1, 1);
tableLayoutPanel1.Controls.Add(txtMailadresse, 1, 2);
tableLayoutPanel1.Controls.Add(txtAdresse, 1, 3);
tableLayoutPanel1.Controls.Add(dataGridViewWpVersionen, 0, 0);
tableLayoutPanel1.Controls.Add(gridControl1, 0, 0);
tableLayoutPanel1.Dock = DockStyle.Fill;
tableLayoutPanel1.Location = new Point(0, 0);
tableLayoutPanel1.Name = "tableLayoutPanel1";
@ -292,6 +294,10 @@ namespace Firmendatenbank
tableLayoutPanel1.RowStyles.Add(new RowStyle(SizeType.Absolute, 30F));
tableLayoutPanel1.RowStyles.Add(new RowStyle(SizeType.Absolute, 30F));
tableLayoutPanel1.RowStyles.Add(new RowStyle(SizeType.Absolute, 30F));
tableLayoutPanel1.RowStyles.Add(new RowStyle(SizeType.Absolute, 20F));
tableLayoutPanel1.RowStyles.Add(new RowStyle(SizeType.Absolute, 20F));
tableLayoutPanel1.RowStyles.Add(new RowStyle(SizeType.Absolute, 20F));
tableLayoutPanel1.RowStyles.Add(new RowStyle(SizeType.Absolute, 20F));
tableLayoutPanel1.Size = new Size(1050, 635);
tableLayoutPanel1.TabIndex = 21;
//
@ -304,16 +310,22 @@ namespace Firmendatenbank
txtStatus.Size = new Size(269, 23);
txtStatus.TabIndex = 22;
//
// dataGridViewWpVersionen
// gridControl1
//
dataGridViewWpVersionen.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.AutoSize;
tableLayoutPanel1.SetColumnSpan(dataGridViewWpVersionen, 4);
dataGridViewWpVersionen.Dock = DockStyle.Fill;
dataGridViewWpVersionen.Location = new Point(3, 3);
dataGridViewWpVersionen.Name = "dataGridViewWpVersionen";
dataGridViewWpVersionen.Size = new Size(1044, 359);
dataGridViewWpVersionen.TabIndex = 24;
dataGridViewWpVersionen.CellClick += dataGridViewWpVersionen_CellClick;
tableLayoutPanel1.SetColumnSpan(gridControl1, 4);
gridControl1.Dock = DockStyle.Fill;
gridControl1.Location = new Point(3, 3);
gridControl1.MainView = gridView1;
gridControl1.Name = "gridControl1";
gridControl1.Size = new Size(1044, 359);
gridControl1.TabIndex = 25;
gridControl1.ViewCollection.AddRange(new DevExpress.XtraGrid.Views.Base.BaseView[] { gridView1 });
//
// gridView1
//
gridView1.GridControl = gridControl1;
gridView1.Name = "gridView1";
gridView1.FocusedRowChanged += gridView1_FocusedRowChanged;
//
// Form1
//
@ -325,14 +337,17 @@ namespace Firmendatenbank
Name = "Form1";
Text = "Firmendaten verwalten";
WindowState = FormWindowState.Maximized;
Shown += Form1_Shown;
tableLayoutPanel1.ResumeLayout(false);
tableLayoutPanel1.PerformLayout();
((System.ComponentModel.ISupportInitialize)dataGridViewWpVersionen).EndInit();
((System.ComponentModel.ISupportInitialize)gridControl1).EndInit();
((System.ComponentModel.ISupportInitialize)gridView1).EndInit();
ResumeLayout(false);
}
private TableLayoutPanel tableLayoutPanel1;
private TextBox txtStatus;
private DataGridView dataGridViewWpVersionen;
private DevExpress.XtraGrid.GridControl gridControl1;
private DevExpress.XtraGrid.Views.Grid.GridView gridView1;
}
}

View File

@ -8,11 +8,11 @@ namespace Firmendatenbank
public partial class Form1 : Form
{
private string connectionString = "Server=192.168.178.201;Database=domainchecker;User ID=root;Password=1td5rugut8;";
private bool isFirstClick = false;
public Form1()
{
InitializeComponent();
LoadWpVersionen();
dataGridViewWpVersionen.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.Fill;
}
private void LoadWpVersionen()
{
@ -34,18 +34,19 @@ namespace Firmendatenbank
}
}
dataGridViewWpVersionen.DataSource = dt;
//dataGridViewWpVersionen.DataSource = dt;
gridControl1.DataSource = dt;
}
private void dataGridViewWpVersionen_CellClick(object sender, DataGridViewCellEventArgs e)
{
DataGridViewRow row = dataGridViewWpVersionen.Rows[e.RowIndex];
txtDomain.Text = row.Cells["domain"].Value.ToString();
txtStatus.Text = row.Cells["status"].Value.ToString();
//DataGridViewRow row = dataGridViewWpVersionen.Rows[e.RowIndex];
//txtDomain.Text = row.Cells["domain"].Value.ToString();
//txtStatus.Text = row.Cells["status"].Value.ToString();
// Lade bestehende Firmendaten
LoadFirmendaten(txtDomain.Text);
//// Lade bestehende Firmendaten
//LoadFirmendaten(txtDomain.Text);
}
private void LoadFirmendaten(string domain)
@ -137,7 +138,7 @@ namespace Firmendatenbank
private void RefreshGridView()
{
dataGridViewWpVersionen.DataSource = null;
//dataGridViewWpVersionen.DataSource = null;
LoadWpVersionen();
}
private void btnCRM_Click(object sender, EventArgs e)
@ -166,5 +167,24 @@ namespace Firmendatenbank
UseShellExecute = false
});
}
private void gridView1_FocusedRowChanged(object sender, DevExpress.XtraGrid.Views.Base.FocusedRowChangedEventArgs e)
{
if (isFirstClick)
{
// Überprüfe, ob eine Zeile ausgewählt ist
if (gridView1.FocusedRowHandle >= 0)
{
txtDomain.Text = gridView1.GetRowCellValue(e.FocusedRowHandle, "domain").ToString();
txtStatus.Text = gridView1.GetRowCellValue(e.FocusedRowHandle, "status").ToString();
LoadFirmendaten(txtDomain.Text);
}
}
}
private void Form1_Shown(object sender, EventArgs e)
{
isFirstClick = true;
}
}
}