winform

讲一讲快速学习WPF的思路

家住魔仙堡 提交于 2019-12-03 21:03:29
我不想浪费大家的时间,直接奔主题了。 首先大家要明白,WPF跟Winform的区别,优点,缺点。 首先入门来讲 Winform简单点,WPF会难一点。所以第一次接触C# 我推荐用Winform项目去学习。 WPF的优势在于有模板的概念,首先动画效果,或者复杂的布局实现起来比较容易,缺点是代码量大,不容易学会,但是学会之后开发速度能提高。 关于优缺点想进一步了解的话,联系我,微信号:nihao0502 QQ:422782452 这里就不继续讲了,进行下一步。 创建新项目: 下一个就是学习内容: 按照实际项目讲解,学完了直接做项目。 相关视频教程在QQ群:433472922 来源: https://www.cnblogs.com/dm0502/p/11808913.html

winform集成cefSharp,与页面进行交互

人走茶凉 提交于 2019-12-03 11:15:37
/// <summary> /// 为了使网页能够与winForm交互 将 com 的可访问性设置为 true /// </summary> [System.Runtime.InteropServices.ComVisible(true)] public partial class Form1 : Form { /// <summary> /// 声明变量 /// </summary> private CefSharp.CefSettings _settings; ChromiumWebBrowser _browser; public Form1() { try { InitializeComponent(); //初始化cefSharp AppLog.Info("cefSharp init ..."); _settings = new CefSharp.CefSettings(); CefSharp.Cef.Initialize(_settings); //下面设置,减少白屏的发生,此为cefSharp的bug if (!_settings.MultiThreadedMessageLoop) { Application.Idle += (sender, e) => { Cef.DoMessageLoopWork(); }; } AppLog.Info("cefSharp init

winform屏蔽鼠标右键

久未见 提交于 2019-12-03 11:13:06
/// <summary> /// 屏蔽右键 /// </summary> internal class MenuHandler : IContextMenuHandler { public bool OnBeforeContextMenu(IWebBrowser browser, IBrowser ibrower, IFrame iframe, IContextMenuParams icontextmenuparams, IMenuModel imenumodel) { return false; } void CefSharp.IContextMenuHandler.OnBeforeContextMenu(CefSharp.IWebBrowser browserControl, CefSharp.IBrowser browser, CefSharp.IFrame frame, CefSharp.IContextMenuParams parameters, CefSharp.IMenuModel model) { model.Clear(); } bool CefSharp.IContextMenuHandler.OnContextMenuCommand(CefSharp.IWebBrowser browserControl, CefSharp.IBrowser browser,

winform使用钩子限制windows热键

限于喜欢 提交于 2019-12-03 11:12:08
新增类KeybordHookProc using System; using System.Collections.Generic; using System.Diagnostics; using System.IO; using System.Linq; using System.Reflection; using System.Runtime.InteropServices; using System.Text; using System.Windows.Forms; namespace HookDemo { /// <summary> /// 这个类可以让你得到一个在运行中程序的所有键盘事件 /// 并且引发一个带KeyEventArgs和MouseEventArgs参数的.NET事件以便你很容易使用这些信息 /// </summary> public class KeyBordHook { private const byte LLKHF_ALTDOWN = 0x20; private const byte VK_CAPITAL = 0x14; private const byte VK_ESCAPE = 0x1B; private const byte VK_F4 = 0x73; private const byte VK_LCONTROL = 0xA2; private

winform操作windows系统计算器

自作多情 提交于 2019-12-03 11:10:42
winform对系统计算器的调用,启动,最大化最小化显示,在mainwindow设置topmost=true时,正常显示计算器并置顶。 /// <summary> /// 获取窗体的句柄函数 /// </summary> /// <param name="lpClassName">窗口类名</param> /// <param name="lpWindowName">窗口标题名</param> /// <returns>返回句柄</returns> [DllImport("user32.dll", EntryPoint = "FindWindow", SetLastError = true)] public static extern IntPtr FindWindow(string lpClassName, string lpWindowName); /// <summary> /// 窗体的显示控制 /// </summary> /// <param name="hWnd">句柄</param> /// <param name="nCmdShow"> /// HIDE = 0 /// NORMAL = 1 /// MAXIMIZE = 3 /// SHOWNOACTIVATE = 4 /// SHOW = 5 /// MINIMIZE = 6 /// RESTORE = 9 /

Opening a WinForm with TopMost=true but not having it steal focus?

匿名 (未验证) 提交于 2019-12-03 03:12:02
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: I have a form that pops up on a user's screen and has TopMost=true , but it steals the focus. How can I get it to not steal focus when it first appears? 回答1: Paste this code in your form: protected override bool ShowWithoutActivation { get { return true; } } 回答2: This is what worked for me. It provides TopMost but without focus-stealing. protected override bool ShowWithoutActivation { get { return true; } } private const int WS_EX_TOPMOST = 0x00000008; protected override CreateParams CreateParams { get { CreateParams createParams = base

Syntax-highlighting textbox for Winforms, ASP.NET, WPF

匿名 (未验证) 提交于 2019-12-03 03:04:01
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: I'm looking for a syntax-highlighting Textbox component, preferably free, with source, and capable of being used in Winforms, ASP.NET and WPF alike. Also, it should support not just display, but also editing contents. I've discovered the excellent, FREE ActiPro SyntaxHighlighter for ASP.NET but that's unfortunately ONLY for ASP.NET and it only displays text in syntax highlighted manner, it has no editing capabilities..... I also know of the ICSharp Text Editor component that's part of SharpDevelop but that's then a standalone, but Winforms

WinForm binding radio button

匿名 (未验证) 提交于 2019-12-03 02:56:01
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: I use VS2010 and then drag and drop Member datagridview to design view. After that I drag and drop name member textfield to design view and then try to edit and save. It's work properly. And then I drag and drop sex radio button to design view. But binding it does't work. How can I binding in this situation? 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 Test7 { public partial class Form1 : Form {

Visual Studio 2008 Winform designer fails to load Form which inherits from generic class

匿名 (未验证) 提交于 2019-12-03 02:44:02
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: i have a winforms project, and i created a class on assembly A that inherits from System.Windows.Forms.Form to serve as a base class for various forms on my project, the base class is something like: public partial class DataForm : Form where T : class { T currentRecord; protected T CurrentRecord { get { return currentRecord; } set { currentRecord = value; CurrentRecordChanged(); } } } Now, when i create a form on assembly B that inherits from my DataForm the designer won't load, but if i compile it the app runs fine. The form looks like:

winform 集成 log4net

狂风中的少年 提交于 2019-12-03 02:03:21
1.引入库log4net.dll 2.展开项目文件下的Properties文件夹,打开AssemblyInfo.cs并在AssemblyInfo.cs中添加一行:在AssemblyInfo.cs中添加一行:(其中log4net.config对应配置文件名) [assembly: log4net.Config.XmlConfigurator(ConfigFile = "log4net.config", ConfigFileExtension = "config", Watch = true)] 3.添加log4net.config配置文件: <?xml version="1.0" encoding="utf-8" ?> <configuration> <configSections> <section name="log4net" type="System.Configuration.IgnoreSectionHandler"/> </configSections> <log4net> <appender name="RollingLogFileAppender" type="log4net.Appender.RollingFileAppender"> <file value="log\logfile.log"/> <appendToFile value="true"/>