没有合适的资源?快使用搜索试试~ 我知道了~
C#控件大小随窗口改变的另一种方法(不包括字体)
需积分: 16 4 下载量 12 浏览量
2017-03-09
17:20:57
上传
评论
收藏 2KB TXT 举报
温馨提示
试读
2页
C#控件大小随窗口改变的另一种方法(不包括字体)
资源推荐
资源详情
资源评论
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
namespace WindowsFormsApplication1
{
public partial class Form1 : Form
{
public static void AutoScale(Form frm)
{
frm.Tag = frm.Width.ToString() + "," + frm.Height.ToString();
frm.SizeChanged += new EventHandler(Form1_SizeChanged);
}
static void Form1_SizeChanged(object sender, EventArgs e)
{
string[] tmp = ((Form)sender).Tag.ToString().Split(',');
float width = (float)((Form)sender).Width / (float)Convert.ToInt16(tmp[0]);
float heigth = (float)((Form)sender).Height / (float)Convert.ToInt16(tmp[1]);
// Single currentSize = Convert.ToSingle((float)Convert.ToInt16(tmp[2]));
((Form)sender).Tag = ((Form)sender).Width.ToString() + "," + ((Form)sender).Height;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
namespace WindowsFormsApplication1
{
public partial class Form1 : Form
{
public static void AutoScale(Form frm)
{
frm.Tag = frm.Width.ToString() + "," + frm.Height.ToString();
frm.SizeChanged += new EventHandler(Form1_SizeChanged);
}
static void Form1_SizeChanged(object sender, EventArgs e)
{
string[] tmp = ((Form)sender).Tag.ToString().Split(',');
float width = (float)((Form)sender).Width / (float)Convert.ToInt16(tmp[0]);
float heigth = (float)((Form)sender).Height / (float)Convert.ToInt16(tmp[1]);
// Single currentSize = Convert.ToSingle((float)Convert.ToInt16(tmp[2]));
((Form)sender).Tag = ((Form)sender).Width.ToString() + "," + ((Form)sender).Height;
资源评论
数据狂魔
- 粉丝: 1
- 资源: 1
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功