C#,WinForm窗体应用程序只能运行一个解决方案
有些软件不想在同一台电脑上运行两个可以用以下方法在Program.cs类里面写上以下代码即可/// <summary>/// 应用程序的主入口点。/// </summary>[STAThread]static void Main(){bool ret;System.Threading.Mutex mutex = new System.Threading.Mutex(true, Applicat…
有些软件不想在同一台电脑上运行两个可以用以下方法在Program.cs类里面写上以下代码即可/// <summary>/// 应用程序的主入口点。/// </summary>[STAThread]static void Main(){bool ret;System.Threading.Mutex mutex = new System.Threading.Mutex(true, Applicat…
C# WinForm实现悬浮在控件(如Button等控件)上有提示信息先看一下效果图以下是核心代码private void Form1_Load(object sender, EventArgs e){ToolTip tooltip = new ToolTip();tooltip.SetToolTip(button1, "这是一个Button");tooltip.SetToolTip(textBox1, "…
如三个Panelpanel1里面有一个panel2 panel2.Dock = DockStyle.Fill;panel2里面有一个panel3 panel3.Dock = DockStyle.Fill;这个时候三个panel重合在一起了,无法选中panel2解决这个问题可以暂时 把panel1的Padding设置一定的内边距,则panel1不会与panel2重合 即可以选中pa…
核心代码public MainFrm(){InitializeComponent();//窗体初始化的时候设置窗体属性this.MaximizedBounds = System.Windows.Forms.Screen.PrimaryScreen.WorkingArea;}
效果图核心代码using System;using System.Drawing;using System.Drawing.Drawing2D;using System.Windows.Forms;namespace TabControlDemo{public class MyTabControl : TabControl{const int CLOSE_SIZE = 15;//原创来自 www.luofenming.compublic MyTabControl(){this.…
先看一下效果,在这里我以TextBox控件为例,其它类型的操作也类似于这样视频讲解地址 https://www.bilibili.com/video/BV1AV4y1M7mR步骤如下(控件名为textBox1)1、注册两个事件,代码如下private void textBox1_DragDrop(object sender, DragEventArgs e){ textBox1.Text…
效果图如下绘制控件代码using System.Drawing;using System.Linq;using System.Reflection;using System.Windows.Forms;namespace WindowsFormsApp2{ public partial class MyPicControl : UserControl { public MyPicControl() { In…
以下核心代码public static Form frm;private void button1_Click(object sender, EventArgs e){ if (frm == null || string.IsNullOrEmpty(frm.Text)) { frm = new Form2(); frm.Show(); } else { frm.WindowState = FormWind…
下面效果图是设置某行背景颜色和某Cells字体颜色下面是核心代码 public partial class Form1 : Form { public Form1() { InitializeComponent(); } private void Form1_Load(object sender, EventArgs e) { this.dataGridView1.Da…