protected override void OnPaint(PaintEventArgs e) { Graphics g = e.Graphics; g.Clear(background); g.DrawRectangle(new Pen(new SolidBrush(border), 2), new Rectangle(1, 1, this.Width - 2, this.Height - 2)); g.Dispose(); base.OnPaint(e); } private void DrawJobs() { try { //Graphics g = pnlView.CreateGraphics(); string[] res = db.ReadDatabase("SELECT MAX(ID) FROM tbl_jobs;"); int x = 30, y = 30, del = 25, job = 0; int.TryParse(res[0], out job); pnlView.Controls.Clear(); /*g.Clear(background); g.DrawRectangle(new Pen(new SolidBrush(border), 2), new Rectangle(1, 1, pnlView.Width - 2, pnlView.Height - 2)); g.Dispose();*/ for (int i = 1; i < job + 1; i++) { res = db.ReadDatabase("SELECT tbl_jobs.name FROM tbl_jobs WHERE ID = " + i + ";"); pnlView.Controls.Add(new Label() { Text = res[0].ToUpper() + ":", Location = new Point(x, y), ForeColor = border, AutoSize = true }); res = db.ReadDatabase("SELECT COUNT(job) FROM tbl_subjobs WHERE job = " + i + ";"); int subjobs = 0, index = 0; int.TryParse(res[0], out subjobs); res = db.ReadDatabase("SELECT ID FROM tbl_subjobs WHERE job = " + i + " ORDER BY ID ASC;"); int.TryParse(res[0], out index); for (int j = index; j < index + subjobs; j++) { res = db.ReadDatabase("SELECT description, done FROM tbl_subjobs WHERE ID = " + j + ";"); pnlView.Controls.Add(new CheckBox() { Text = res[0], Checked = bool.Parse(res[1]), Location = new Point(x + del, y + del), ForeColor = border, AutoSize = true }); y += del; } y += del; } if (job == 0) { pnlView.Controls.Add(new Label() { Text = "Keine Einträge vorhanden.", Location = new Point(x, y), ForeColor = border, Font = new Font(this.Font.FontFamily, this.Font.Size, FontStyle.Bold), AutoSize = true }); y += del; } Button btnUpdateJobs = new Button(); btnUpdateJobs.Text = "Speichern"; btnUpdateJobs.Height = 41; btnUpdateJobs.Width = 130; btnUpdateJobs.FlatStyle = FlatStyle.Flat; btnUpdateJobs.ForeColor = border; btnUpdateJobs.Click += btnUpdateJobs_Click; btnUpdateJobs.MouseHover += General_MouseHover; btnUpdateJobs.Location = new Point(x, y); pnlView.Controls.Add(btnUpdateJobs); } catch (Exception exc) { Dialog_Message.ShowDialog("Fehler", exc.Message, Dialog_Message.DialogButtons.OK, Dialog_Message.DialogSymbol.Error); } } private void pnlView_Paint(object sender, PaintEventArgs e) { Graphics g = e.Graphics; g.Clear(background); g.DrawRectangle(new Pen(new SolidBrush(border), 2), new Rectangle(1, 1, pnlView.Width - 2, pnlView.Height - 2)); g.Dispose(); }