1-) C# RMOS - flowlayoutpanel de double click mouse hover üzerine gelince için aşağıdakini kullan
kaynak kodlar : https://github.com/ramazanhaber/FlowLayoutBasic
double click için aşağıdaki kodun yerine
System.Windows.Forms.Button btn = new System.Windows.Forms.Button();
Aşağıdaki kodu kullanın
MyButton button = new MyButton();
MyButton.cs sınıfı ise ektedir. NameSpace ismini değiştirmeniz yeterlidir.
kodu :
using System.Windows.Forms;
namespace FlowLayoutPanel
{
public class MyButton : Button
{
public MyButton()
{
SetStyle(ControlStyles.StandardClick | ControlStyles.StandardDoubleClick, true);
}
}
}
public Form1()
{
InitializeComponent();
for (int i = 0; i < 10; i++)
{
MyFlowDoldur("Button " + i);
}
}
public void MyFlowDoldur(string MasaIsmi)
{
try
{
MyButton button = new MyButton();
button.FlatStyle = FlatStyle.Flat;
button.Height = 70;
button.Width = 135;
button.ForeColor = Color.White;
button.Font = new Font("Microsoft Sans Serif", 11, FontStyle.Bold);
button.BackColor = Color.Blue;
button.Text = MasaIsmi;
button.Tag = MasaIsmi;
flowLayoutPanel1.Controls.Add(button);
button.Click += btnNew_Click;
button.DoubleClick += btnDoubleNew_Click;
button.MouseHover += ButtonName_MouseHover;
}
catch (Exception ex)
{
MessageBox.Show("HATA! MyFlowDoldur()" + ex.Message);
}
}
2-) MOUSE HOVER( MOUSE ÜZERİNE GELDİĞİNDE)
button.MouseHover += ButtonName_MouseHover;
private void ButtonName_MouseHover(object sender, EventArgs e)
{
Button clickedButton = (Button)sender;
string text = clickedButton.Text;
Console.WriteLine("hover " + text);
System.Windows.Forms.ToolTip ToolTip1 = new System.Windows.Forms.ToolTip();
ToolTip1.SetToolTip(clickedButton, "Button hover " + text+ "\nButton hover " + text);
}
HEPSİ
using System;
using System.Drawing;
using System.Windows.Forms;
namespace FlowLayoutPanel
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
for (int i = 0; i < 10; i++)
{
MyFlowDoldur("Button " + i);
}
}
private void button1_Click(object sender, EventArgs e)
{
}
public void MyFlowDoldur(string MasaIsmi)
{
try
{
MyButton button = new MyButton();
button.FlatStyle = FlatStyle.Flat;
button.Height = 70;
button.Width = 135;
button.ForeColor = Color.White;
button.Font = new Font("Microsoft Sans Serif", 11, FontStyle.Bold);
button.BackColor = Color.Blue;
button.Text = MasaIsmi;
button.Tag = MasaIsmi;
flowLayoutPanel1.Controls.Add(button);
button.Click += btnNew_Click;
button.DoubleClick += btnDoubleNew_Click;
button.MouseHover += ButtonName_MouseHover;
}
catch (Exception ex)
{
MessageBox.Show("HATA! MyFlowDoldur()" + ex.Message);
}
}
private void btnNew_Click(object sender, EventArgs e)
{
Button clickedButton = (Button)sender;
string text = clickedButton.Text;
//MessageBox.Show(text);
Console.WriteLine("click "+text);
}
private void btnDoubleNew_Click(object sender, EventArgs e)
{
Button clickedButton = (Button)sender;
string text = clickedButton.Text;
MessageBox.Show("double "+text);
}
private void ButtonName_MouseHover(object sender, EventArgs e)
{
Button clickedButton = (Button)sender;
string text = clickedButton.Text;
Console.WriteLine("hover " + text);
System.Windows.Forms.ToolTip ToolTip1 = new System.Windows.Forms.ToolTip();
ToolTip1.SetToolTip(clickedButton, "Button hover " + text+ "\nButton hover " + text);
}
}
}