102 lines
2.7 KiB
C#
102 lines
2.7 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
using System.ComponentModel;
|
|
using System.Data;
|
|
using System.Drawing;
|
|
using System.Linq;
|
|
using System.Text;
|
|
using System.Threading.Tasks;
|
|
using System.Windows.Forms;
|
|
|
|
namespace Deckungsbeitrag.UserControls
|
|
{
|
|
public partial class KundenControl : UserControl
|
|
{
|
|
private Label lblKunde;
|
|
private Label lblRegion;
|
|
private FlowLayoutPanel flp; // ← Field deklarieren!
|
|
|
|
public string KundenName
|
|
{
|
|
get => lblKunde.Text;
|
|
set => lblKunde.Text = value;
|
|
}
|
|
public string Region
|
|
{
|
|
get => lblRegion.Text;
|
|
set => lblRegion.Text = value;
|
|
}
|
|
|
|
public KundenControl()
|
|
{
|
|
InitializeComponent();
|
|
SetupControl();
|
|
}
|
|
|
|
public KundenControl(string name, string region = "") : this()
|
|
{
|
|
KundenName = name;
|
|
Region = region;
|
|
}
|
|
private void SetupControl()
|
|
{
|
|
this.Size = new Size(200, 35); // Breiter für 2 Labels
|
|
this.BackColor = Color.LightSteelBlue;
|
|
this.BorderStyle = BorderStyle.FixedSingle;
|
|
|
|
// FlowLayoutPanel für horizontale Anordnung
|
|
flp = new FlowLayoutPanel
|
|
{
|
|
Dock = DockStyle.Fill,
|
|
FlowDirection = FlowDirection.LeftToRight,
|
|
AutoSize = true,
|
|
Padding = new Padding(4)
|
|
};
|
|
|
|
// Kunde-Label (links, fett)
|
|
lblKunde = new Label
|
|
{
|
|
Text = "Max Mustermann",
|
|
TextAlign = ContentAlignment.MiddleLeft,
|
|
Font = new Font("Segoe UI", 12F, FontStyle.Bold),
|
|
Margin = new Padding(0, 2, 5, 2), // Abstand rechts
|
|
Anchor = AnchorStyles.None,
|
|
AutoSize = true
|
|
};
|
|
|
|
// Region-Label (rechts, klein)
|
|
lblRegion = new Label
|
|
{
|
|
Text = "Salzburg",
|
|
TextAlign = ContentAlignment.MiddleLeft,
|
|
Font = new Font("Segoe UI", 10F, FontStyle.Regular),
|
|
ForeColor = Color.DarkBlue,
|
|
Margin = new Padding(0),
|
|
Anchor = AnchorStyles.None,
|
|
AutoSize = true
|
|
};
|
|
|
|
|
|
flp.Controls.Add(lblKunde);
|
|
flp.Controls.Add(lblRegion);
|
|
this.Controls.Add(flp);
|
|
|
|
// ★★★ MOUSE-EVENTS DURCHREICHEN zu EINEM Handler ★★★
|
|
flp.MouseDown += KundenControl_MouseDown;
|
|
lblKunde.MouseDown += KundenControl_MouseDown;
|
|
lblRegion.MouseDown += KundenControl_MouseDown;
|
|
}
|
|
private void KundenControl_MouseDown(object sender, MouseEventArgs e)
|
|
{
|
|
if (e.Button == MouseButtons.Left)
|
|
{
|
|
this.DoDragDrop(new DataObject("KundeData", this), DragDropEffects.Copy);
|
|
}
|
|
}
|
|
public object Clone()
|
|
{
|
|
return new KundenControl(this.KundenName, this.Region);
|
|
}
|
|
}
|
|
}
|
|
//TODO: Design des Controls anpassen. Eventuell im Designer erstellen. |