分类 C# 下的文章
背景我们自己编写程序的界面,会遇到各种屏幕分辨率,只有自适应才能显的美观。实际上,做到这点也很简单,就是首先记录窗体和它上面控件的初始位置和大小,当窗体改变比例时,其控件的位置和大小也按此比例变化即可。(因为窗体上控件的位置和大小是相对于自己所在的窗体的。)使用方法声明自适应辅助类实例为窗体添加Load事件,并在其方法Form\_Load中,调用自适应辅助类方法,记录窗体和其控件初始位置和大小为窗体添加SizeChanged事件,并在其方法Form\_SizeChanged中,调用自适应辅助类的自适应方法,完成自适应完整代码自适应窗体public partial class Form1 : Form { // 声明自适应辅助类实例 AutoSizeFormHelper asf = new AutoSizeFormHelper(); public Form1() { InitializeComponent(); } // 为窗体添加Load事件,并在其方法Form1_Load中,调用自适应辅助类方法,记录窗体和其控...
WinForm窗体及其控件自适应各种屏幕分辨率

WinForm窗体及其控件自适应各种屏幕分辨率

通常情况下,直接调用WebBrowser控件的时候默认是IE7内核,实在是不美观。using Microsoft.Win32; using System; using System.ComponentModel; namespace ClassLibrary { /// <summary> /// 设置Webbrowser控件所用IE内核版本 /// </summary> public class WebBrowserHelper { /// 修改注册表信息来兼容当前程序 /// /// </summary> public static void SetWebBrowserFeatures(int ieVersion) { // Win8及以上,默认浏览器IE10及以上 OperatingSystem os = Environment.OSVersion; ...
C#设置WebBrowser默认的IE内核

C#设置WebBrowser默认的IE内核

using System; using System.Collections.Generic; using System.Diagnostics; using System.Runtime.Serialization; using System.Security.Cryptography; using System.Text; // // Copyright (c) 2006 Damien Miller <djm@mindrot.org> // Copyright (c) 2013 Ryan D. Emerle // // Permission to use, copy, modify, and distribute this software for any // purpose with or without fee is hereby granted, provided that the above // copyright notice and this permission notice appear in all copies. // // THE S...
BCrypt算法的C#实现

BCrypt算法的C#实现

TreeView本身不支持透明背景,重写WndProc以支持背景图片。using System; using System.Drawing; using System.Drawing.Drawing2D; using System.Windows.Forms; using System.ComponentModel; using System.Runtime.InteropServices; namespace MyControl { /// <summary> /// Displays a hierarchical collection of labeled items, each represented by a System.Windows.Forms.TreeNode. /// </summary> [ //Use the same attibutes as TreeView DesignerAttribute("System.Windows.Forms.Design.TreeViewDe...
winform中TreeView透明背景

winform中TreeView透明背景

我们在做winform应用的时候,大部分情况下都会碰到使用多线程控制界面上控件信息的问题。然而我们并不能用传统方法来做这个问题,下面我将详细的介绍。首先来看传统方法:public partial class Form1 : Form { public Form1() { InitializeComponent(); } private void Form1_Load(object sender, EventArgs e) { Thread thread = new Thread(ThreadFuntion); thread.IsBackground = true; thread.Start(); } private void ThreadFuntion() { while (true) { this.textBox1.Text = DateTime.Now.ToString(); Thr...
c#中如何跨线程调用windows窗体控件

c#中如何跨线程调用windows窗体控件