Tag: winforms

如何让我的申请有30天的试用期

如何在我的c#windows应用程序中创建试用期设置文件30天?

显示带有WPF,Winforms和双显示器的窗口

我有一个2监视器和一个启动WPF窗口的WinForm应用程序。 我想获得WinForm所在的屏幕,并在同一屏幕上显示WPF窗口。 我怎样才能做到这一点?

在C#中的Picturebox上绘制一个箭头

我希望能够从一个鼠标点击位置绘制一个直箭头,就像你在PowerPoint中一样。 它也需要能够在PictureBox上绘图。

使用后台工作程序 – 更新ProgressBar以了解递归方法的进度

下面是一个方法,我想发送到后台工作者,但我正在努力如何根据如何创建我的方法来做到这一点。 尽管如此,它不会返回任何正常的内容,但每次调用时都需要一个directoryInfo对象。 private void getSizeForTargetDirectory(DirectoryInfo dtar) { // generate a collection of objects. files comes first and then directories. foreach (Object item in collection ) { if (item == file) { track the size of the files as you encounter. } else if (item == directory) { // found a new directory, recall the method. […]

forms时未配置定时器

我试图理解为什么在创建它的form时不会处理Windows.Forms.Timer 。 我有这个简单的forms: public partial class Form1 : Form { private System.Windows.Forms.Timer timer; public Form1() { InitializeComponent(); } private void Form1_Load(object sender, EventArgs e) { timer = new Timer(); timer.Interval = 1000; timer.Tick += new EventHandler(OnTimer); timer.Enabled = true; } private void OnTimer(Object source, EventArgs e) { Debug.WriteLine(“OnTimer entered”); } private void Form1_FormClosed(object sender, FormClosedEventArgs […]

通过ODBC执行参数化SQL StoredProcedure

在C#WinForms应用程序中,我必须在MS SQL Express服务器上执行参数化存储过程。 数据库连接工作,过程工作,但我收到一条错误消息: 42000:缺少参数’@KundenEmail’ 虽然我确定我正确添加了参数。 也许你们中的一些人可以看看 – 我不知道该怎么搜索…… OdbcConnection ODBCConnection = new OdbcConnection(); try { ODBCConnection.ConnectionString = ODBCConnectionString; ODBCConnection.Open(); } catch (Exception DatabaseConnectionEx) { if (ODBCConnection != null) ODBCConnection.Dispose(); // Error Message return null; } OdbcParameter ODBCParameter = new OdbcParameter(“@KundenEmail”, OdbcType.NChar, 50); ODBCParameter.Value = KundenEmail; OdbcCommand ODBCCommand = new OdbcCommand(“getDetailsFromEmail”, ODBCConnection); ODBCCommand.CommandType = CommandType.StoredProcedure; […]

有没有办法检测用户控件外的鼠标点击?

我正在创建一个自定义下拉框,我想在下拉框外单击鼠标时进行注册,以便隐藏它。 是否可以检测到控件外的点击? 或者我应该在包含的表单上制作一些机制,并在任何下拉框打开时检查鼠标点击?

如何将CenterParent转换为非模态forms

我有一个非模态子表单,从父表单打开。 我需要将子表单居中到其父表单。 我已将子表单的属性设置为CenterParent并尝试了此操作: Form2 f = new Form2(); f.Show(this); 但无济于事。 这适用于模态forms,但非模态forms则不然。 任何简单的解决方案,还是需要我通过所有数学计算来确定其位置为中心?

将Excel文件从.csv转换为.xlsx

我希望我的应用程序去找一个csv excel文件并将其转换为.xlsx文件。 这就是我目前正在做的事情; var fileName = @”Z:\0328\orders\PurchaseOrder.csv”; FileInfo f = new FileInfo(fileName); f.MoveTo(Path.ChangeExtension(fileName, “.xlsx”)); var Newfile = @”Z:\0328\orders\PurchaseOrder.xlsx”; 现在这确实有效 。 它将文件扩展名更改为我想要的格式。 然而,该文件然后变得“腐败”或至少Excel拒绝打开它,当我尝试进一步冒险时我的应用程序也不会。 有没有人有解决方案/解决方案?

禁用时如何更改富文本框的背景颜色?

每当我将RichTextBox.Enabled属性设置为false时,其背景颜色将自动设置为灰色,因为它设置为控制面板中设置的系统颜色。 即使将其设置为禁用,如何将其颜色更改为黑色?