Tag: winforms

UI控件在Windows窗体应用程序中重叠和字体问题

我制作了一个Windows窗体应用程序。 我有一个带有一些控件的表单。 控件重叠,并且字体也会自动更改,在某些地方,字体在按钮,文本框中变为白色。 我附上一张图片以便更多理解。 1 : 这在一些最终用户的系统中发生,我无法找到为什么会出现此问题。 任何帮助,将不胜感激。 Thnx提前

单击C#表单X按钮

如何通过单击X按钮或(this.Close())来确定表单是否已关闭?

可以在WinForms应用程序中使用CKEditor进行(X)HTML编辑吗?

我已经将winforms html编辑器的代码改编为C#(见下文)。 是否可以使用CKEditor? 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 WebEditorTest { /// /// https://stackoverflow.com/questions/214124/winforms-html-editor /// public partial class Form1 : Form { public Form1() { InitializeComponent(); } private void Form1_Load(object sender, EventArgs e) { webBrowser1.Navigate(“about:blank”); Application.DoEvents(); webBrowser1.Document.OpenNew(false).Write(“Edit this text”); foreach (HtmlElement el in webBrowser1.Document.All) […]

设置表单最小大小

我有一个带有相当大边框的C#表单。 我想将最小大小设置为(850,760)(默认起始大小),但是当我尝试在表单属性菜单中设置值时,它会不断将其更改为(850,720)。 我尝试按代码设置它如下: this.minimumSize = new System.Drawing.Size(850, 760); 但是当我运行代码时,我仍然可以垂直缩小我的表单。 有没有人对问题可能是什么有任何想法? 编辑:我使用两个显示器,一个标准1280×1024和另一个宽屏1366×768,这可能是问题? 在这种情况下有没有办法测试用户的显示器分辨率并根据它设置最小尺寸?

Zed-Graph Set以编程方式缩放为默认值

我有一个winforms应用程序,它使用zed-graph库来绘制图形。 当我右键单击控件时(在应用程序运行时)会出现一个上下文菜单,我可以选择Set Scale to default 。 如何Set Scale to default编程方式将此Set Scale to default -behaviour?

WPF应用程序是否需要使用XAML?

我想学习C#,似乎每个人都在使用WinForms切换到使用WPF。 由于使用了用于构建Forms的.XAML文件,WPF应用程序对我来说似乎更加复杂。 在我真正参与之前,我只想问一下,XAML文件是构建WPF应用程序的唯一方法吗? 有更简单的方法吗? 我知道我可以学习使用WinForms,这看起来要容易得多,因为你基本上有一个Form对象可以使用代码,但就像我提到的那样我认为最好构建WPF应用程序

启动时Visual Studio Debuggerexception

启动我的WinForms项目(项目只包含一个源文件,Program.cs)时,调试器在以下exception中没有堆栈跟踪的情况下中断: System.ArgumentNullException was unhandled Message=”Value cannot be null.\r\nParameter name: activationContext” Source=”mscorlib” ParamName=”activationContext” StackTrace: at System.Runtime.Hosting.ApplicationActivator.CreateInstance(ActivationContext activationContext, String[] activationCustomData) at System.Runtime.Hosting.ApplicationActivator.CreateInstance(ActivationContext activationContext) at System.Activator.CreateInstance(ActivationContext activationContext) at Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssemblyDebugInZone() at System.Threading.ThreadHelper.ThreadStart_Context(Object state) at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state) at System.Threading.ThreadHelper.ThreadStart() InnerException: 在我的Main()函数输入之前抛出此exception,所以我不知道如何解决这个问题。 这是在Visual C#2008中。该项目是为ClickOnce发布而设置的。

该线程已退出Windows窗体中的代码0

我在Windows窗体中退出线程时遇到问题。 我有经典的Windows窗体,它正在运行。 我需要在每个时间段做一些事情,所以我补充说: TimerCallback timerDelegate = new TimerCallback(this.TryDoSomething); int period = 10 * 1000; // to miliseconds System.Threading.Timer stateTimer = new System.Threading.Timer(timerDelegate, null, period, period); 方法DoSomething由几个线程(主线程和这个计时器)调用,所以我这样覆盖它: private void TryDoSomething(object o) { lock (tryDoSomethingMutex) { if (this.dataGridView1.InvokeRequired) { RefreshCallback d = new RefreshCallback(DoSomething); this.Invoke(d, new object[] { o }); } else { this.DoSomething(o); } } } […]

在Form Load之前,数据绑定不起作用 – 仅在Form加载后初始化ComboBox项

我在winform上有两个ComboBox,一个包含List“MyList”中的所有值,另一个我希望从第一个选定索引中获取所有值。 但我认为将项目加载到ComboBox中时会出现问题。 public partial class Form1 : Form { public Form1() { ComboBox box = new ComboBox(); box.DropDownStyle = ComboBoxStyle.DropDownList; box.DataSource = MyList.ToList(); box.SelectedIndexChanged += new EventHandler(ComboBox_SelectedIndexChanged); Tab_Page.Controls.Add(box); ComboBox box2 = new ComboBox(); box2.DropDownStyle = ComboBoxStyle.DropDownList; foreach (object o in box.Items) { box2.Items.Add(o); } Tab_Page.Controls.Add(box2); box2.Items.RemoveAt(0); //This last line throws an error //”InvalidArgument=Value of ‘0’ […]

WinForm ScrollViewer

我在WPF中有一个使用ScrollViewr的应用程序,我想将它移植到WinForms,是否有一个等效的WinForms控件? 原因: WPF程序很慢,我似乎无法学习如何正确渲染程序(GameOfLife)。 码: