mikebai.com

  • Home
  • dev
  • DotNET
  • M365
  • 搞笑
  • 杂七杂八
  • FocusDict
DotNET
DotNET

c# winform适配高dpi

1)添加app.manifest文件 改文件创建后的路径 > "myproj\Properties\app.manifest" 方法1 打开vs2005、vs2008等工程,在【解决方案资源管理器】里查看是否有app.manifest这个文件,如果没有的话,通过以下方法创建: 方法1: 1、在【解决方案资源管理器】右键工程名称选择属性; 2、在弹出的该对话框中,选择【安全性】选项卡。 3、勾选【启用ClickOnce安全设置】,并选中【这是完全可信的应用程序】。 4、保存工程,这时候app.manifest就自动创建了。 方法2 为工程项目添加一个类,应用程序清单文件(app.manifest)。 高 DPI 支持 - Windows Forms .NET Framework | Microsoft Learn 仅在以 .NET Framework 4.7 为目标并在从 Windows 10 创意者更新开始的 Windows 操作系统上运行的应用程序中提供支持高 DPI 感知的新 Windows 窗体功能。 此外,若要在 Windows 窗体应用程序中配置高 DPI 支持,必须执行以下操作: 声明与 Windows 10 的兼容性。为此,请将以下内容添加到清单文件: XML <compatibility xmlns="urn:schemas-microsoft-com:compatibility.v1"> <application> <!-- Windows 10 compatibility --> <supportedOS Id="{8e0f7a12-bfb3-4fe8-b9a5-48fd50a15a9a}" /> </application> </compatibility> プロジェクトにアプリケーションマニフェストファイルapp.manifestを追加し、下記の設定を記入します。 この設定でWindowsが高DPIサポート済と認識してくれるので、表示がぼやけることが無くなります。 <application xmlns="urn:schemas-microsoft-com:asm.v3"> <windowsSettings> <dpiAware xmlns="http://schemas.microsoft.com/SMI/2005/WindowsSettings">true</dpiAware> </windowsSettings> </application> 在 app.config 文件中启用每监视器 DPI 感知。Windows 窗体引入了一个新的 <System.Windows.Forms.ApplicationConfigurationSection> 元素,用于支持从 .NET Framework 4.7 开始添加的新增功能和自定义项。 若要利用支持高 DPI 的新功能,请将以下内容添加到应用程序配置文件。 XML <configuration> <!-- ... other xml settings ... --> <System.Windows.Forms.ApplicationConfigurationSection> <add key="DpiAwareness" value="PerMonitorV2" /> </System.Windows.Forms.ApplicationConfigurationSection> </configuration>   最后设置指定容器模式为dpi this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Dpi; 注意form中控件字体也可能导致ui崩溃

2025-04-28 0comments 43hotness 0likes mikebai Read all
DotNET

MVC的cshtml的介绍

cshtml 是 MVC3 之后新增的视图文件,跟原先的 aspx 很相似。 区别主要在于二者的解释引擎不同。aspx 采用的是 WebForm Engine,而 cshtml 则是 Razor Rendering Engine。引擎的变化直接导致语法发生变化。aspx 中我们经常使用 <% test; %>这种,在 cshtml 中则改为 @{ test; } 这种更为简洁的写法。 只能在 MVC3 或更高版本等支持 Razor 的框架里使用 cshtml。 比较: ASPX文件是微软的在服务器端运行的动态网页文件,通过IIS解析执行后可以得到动态页面,是微软推出的一种新的网络编程方法,而不是ASP的简单升级,因为它的编程方法和ASP有很大的不同,他是在服务器端靠服务器编译执行的程序代码,ASP 使用脚本语言,每次请求的时候,服务器调用脚本解析引擎来解析执行其中的程序代码,而ASP.NET则可以使用多种语言编写,而且是全编译执行的,比ASP 快,而且,不仅仅是快的问题,有很多优点。.asp是asp的文件后缀名,.aspx是asp.net的文件后缀名。 Razor是一种简单的编程语法,用于在网页中嵌入服务器端代码。Razor 语法基于 ASP.NET 框架,该框架是微软的 .NET 框架特别为 web 应用程序开发而设计的组成部分。Razor 语法赋予所有 ASP.NET 的能力,但是使用了简化过的语法,如果您是初学者,则更容易学习,如果您是专家,则更有利于提高生产力。Razor 网页可被描述为带有两种内容的 HTML 页面:HTML 内容和 Razor 代码。当服务器读取这种页面后,在将 HTML 页面发送到浏览器之前,会首先运行 Razor 代码。这些在服务器上执行的代码能够完成浏览器中无法完成的任务,比如访问服务器数据库。服务器代码能够在页面被发送到浏览器之前创建动态的 HTML 内容。 从浏览器来看的话,由服务器代码生成的 HTML 与静态 HTML 内容没有区别。使用 Razor 语法的 ASP.NET 网页拥有特殊的文件扩展名 cshtml(使用 C# 的 Razor 语法)或者 vbhtml(使用 VB 的 Razor语法)

2025-02-13 0comments 102hotness 0likes mikebai Read all
DotNET

aps.net core button click

Handler methods is a particularly nice feature introduced with the new ASP.NET Razor Pages framework . This feature enables you to determine what the user was doing when they requested the page, and to execute logic accordingly without having to resort to a bunch of conditional code. One of the most common tasks in web development is to determine which HTTP verb your visitor has used to request a page. Is this an initial GET request, or has the user POSTed a form? In classic ASP or PHP, you will usually query the Server Variables collection (Request.ServerVariables("REQUEST_METHOD") or $_Server['REQUEST_METHOD']) to determine which verb was used, or you might query the Request.Form collection for the presence or absence of values. The ASP.NET Web Forms and Web Pages frameworks provide convenience methods to differentiate between POST and 

2021-02-22 0comments 141hotness 0likes mikebai Read all
DotNET

Model Binding

Model Binding Model Binding in Razor Pages is the process that takes values from HTTP requests and maps them to handler method parameters or PageModel properties. Model binding reduces the need for the developer to manually extract values from the request and then assign them, one by one, to variables or properties for later processing. This work is repetitive, tedious and error prone, mainly because request values are usually only exposed via string-based indexes. The Problem link To illustrate the role that model binding plays, create a new Razor page with a PageModel and name it ModelBinding.cshtml. Change the code in the content page to the following: @page

2020-06-01 0comments 124hotness 0likes mikebai Read all
DotNET

C# 变量后面跟问号

表示该变量为null时,不执行该语句。 当val=null时 val?.ToLower();返回值=null 没有“?”时,显然要报错的。

2020-02-02 0comments 119hotness 0likes mikebai Read all
DotNET

windows server管理之IIS7 FTP 出现 "530 Valid Hostname is expected"的解决办法

今日在IIS7.5上加了一个FTP站点,创建完ftp用户后,用这个用户在远程登录发现  出现 "530 Valid Hostname is expected" 解决办法: 1.若是你的ftp绑定的域名是ftp.abc.com,用户名为user 则登录时需要用 ftp.abc.com|user; 注意中间用"|"分隔 2.把绑定删除,直接用用户名登录也可以 ———————————————— 版权声明:本文为CSDN博主「ChenZhuYu」的原创文章,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接及本声明。 原文链接:https://blog.csdn.net/chenzhuyu/article/details/50363824

2019-12-27 0comments 131hotness 0likes mikebai Read all
DotNET

excel epplus ref

https://www.paragon-inc.com/blog/easy_excel_interaction_pt5 http://gruffcode.com/2013/10/30/simple-excel-export-with-epplus/ https://stackoverflow.com/questions/13396604/excel-to-datatable-using-epplus-excel-locked-for-editing http://www.jb51.net/article/80065.htm https://code.msdn.microsoft.com/CSASPNETCascadingDropDownLi-0a3f1ecf

2018-04-09 0comments 126hotness 0likes mikebai Read all
DotNET

run visual studio always as administrator

Follow these simple steps: Right Click on "devenv.exe" Click "Troubleshoot compatibility" Click "Troubleshoot program" Check "The program requires additional permissions" Click "Next" Click "Test the program...". It should launch Visual Studio as Administrator Click "Next" Click "Yes, save these settings for this program" Click "Close the troubleshooter" Now the Visual Studio

2018-03-23 0comments 122hotness 0likes mikebai Read all
DotNET

使用ScriptManager管理Script

Tool:Visual Studio 2013 Ultimate OS:Windows Server 2012 .NET Framework : 4.5.1   這是自ASP.NET4.5版就新增的新功能,在ASP.NET Web Forms網站之中,可以利用ScriptManager來管理JavaScript,例如jQuery,讓引用更方便。 建立一個Web Site 使用NuGet下載jQuery,目前版本2.0.3

2018-03-18 0comments 115hotness 0likes mikebai Read all
DotNET

MB.Utility.Log.SingleLog

using System; using System.Collections.Generic; using System.Text; using System.Reflection; using System.IO; namespace MB.Utility.Log {     /// <summary>     ///      /// </summary>     public class SingleLog     {         StreamWriter sw = null;         // string LogFile;             /// <summary>             ///              /// </summary>             /// <param name="assembly"></param>         public SingleLog(Assembly assembly)         {             if (assembly == null)             {                 throw new Exception("未指定程序集~");             }             string directory = Path.GetDirectoryName(assembly.Location) + "\\" + "~LogFile";             string folder = Path.GetFileNameWithoutExtension(assembly.Location);             string fileName = directory + "\\" + folder + "\\" + DateTime.Now.ToString("yyyyMMddHHmm") + ".txt";             if (!Directory.Exists(Path.GetDirectoryName(fileName)))             {                 Directory.CreateDirectory(Path.GetDirectoryName(fileName));             }             bool append = true;             //if (!File.Exists(fileName))             //{             //    File.Create(fileName);             //}             this.sw = new StreamWriter(fileName, append, Encoding.Unicode);         }  …

2018-03-17 0comments 128hotness 0likes mikebai Read all
12345…16

Recent Posts

  • c# winform适配高dpi
  • com.microsoft.sqlserver.jdbc.SQLServerException “trustServerCertificate”属性设置为“false”,但驱动程序无法使用安全套接字层 (SSL) 加密与 SQL Server建立安全连接
  • java -cp 用法介绍
  • HTML 容器元素
  • MVC的cshtml的介绍

Recent Comments

No comments to show.

COPYRIGHT © 2025 mikebai.com. ALL RIGHTS RESERVED.

Theme Kratos Made By Seaton Jiang