我只是想知道在Windows窗体中我是否可以在组合框的边框周围创建一条红线?就像一缕红色然后又一次只是为了表明它已被改变.抓住用户的眼睛或其他东西.我将提供屏幕来表示我想要的东西.
如果有可能,请告诉我在哪里可以查找它以获取一些信息.
我需要在表单加载10秒后显示一条消息.我使用以下代码
private void Form1_Load(object sender, EventArgs e)
{
SetTimeInterval();
}
System.Windows.Forms.Timer MyTimer = new System.Windows.Forms.Timer();
public void SetTimeInterval()
{
MyTimer.Interval = ( 10 * 1000);
MyTimer.Tick += new EventHandler(TimerEventProcessor);
MyTimer.Start();
}
void TimerEventProcessor(Object myObject,EventArgs myEventArgs)
{
MessageBox.Show("TIME UP");
MyTimer.Stop();
MyTimer.Enabled = false;
}
Run Code Online (Sandbox Code Playgroud)
使用MyTimer.Stop()和MyTimer.Enabled = false尝试,但messagebox每10秒显示一次.如何在第一次实例后停止它?
我无法找到如何将光标更改为"指针"或悬停图像时调用的任何内容.
我尝试使用MouseOver,但我无法让它工作.这是我目前的代码;
private void image_Phone_MouseOver(object sender, EventArgs e)
{
Cursor.Current = Cursors.Hand;
}
Run Code Online (Sandbox Code Playgroud)
但是,光标不会改变.
一直在寻找高低,以获得如何做到这一点的答案!我基本上有26个组合框名为comboBox1 - comboBox26,并且想要使用for循环向每个框添加项目,所以我需要将comboBox称为字符串.解释不好,这是我到目前为止的代码;
for (int n = 1; n <= 26; n++)
{
this.["comboBox"].Text.AddRange(new string[]
{"First Item", "second item", "third", "fourth", "fifth"});
}
Run Code Online (Sandbox Code Playgroud)
所以在循环之后,所有26个组合框都应填充该字符串数组.这和我尝试的其他所有东西都会抛出一个错误而且似乎无法找到答案,任何帮助都会很棒!
谢谢
我正在使用带有Winforms的C#创建一个应用程序,现在我需要在热敏打印机上打印销售收据.要做到这一点,我正在创建一个文本文件,并使用它读取它进行打印,PrintDocument 但我不能这样做,因为我不知道如何配置纸张大小,在纸张上对齐文本中心,以及其他配置.当我打印文本文件打印,但所有凌乱,并在打印结束后纸张没有停止.
我怎么能这样做?
试.
private PrintDocument printDocument = new PrintDocument();
private static String RECEIPT = Environment.CurrentDirectory + @"\comprovantes\comprovante.txt";
private String stringToPrint = "";
private void button1_Click(object sender, EventArgs e)
{
generateReceipt();
printReceipt();
}
private void generateReceipt()
{
FileStream fs = new FileStream(COMPROVANTE, FileMode.Create);
StreamWriter writer = new StreamWriter(fs);
writer.WriteLine("==========================================");
writer.WriteLine(" NOME DA EMPRESA AQUI ");
writer.WriteLine("==========================================");
writer.Close();
fs.Close();
}
private void printReceipt()
{
FileStream fs = new FileStream(COMPROVANTE, FileMode.Open);
StreamReader sr = new StreamReader(fs);
stringToPrint = sr.ReadToEnd();
printDocument.PrinterSettings.PrinterName = …Run Code Online (Sandbox Code Playgroud) 我正在将一个复选框数据绑定到一个bindingsource,如果我没有单击该复选框,它将返回一个空值到我的数据库.
这是数据绑定代码:
checkGehuwd.DataBindings.Add("Checked", PersonenBindingSource, "gehuwd", true,
DataSourceUpdateMode.OnPropertyChanged);
Run Code Online (Sandbox Code Playgroud)
我如何返回默认值false?
问候安迪
我已经在Microsoft Visual Studio上构建了Windows窗体应用程序GUI。我是否可以知道在Linux环境中运行应用程序需要执行哪些步骤?提前致谢!
我这样做:
clear();
coinRefundComplete.Visible = true;
state = 0;
System.Threading.Thread.Sleep(4000);
clear();
greeting.Visible = true;
rate.Visible = true;
refundTicket.Visible = true;
currentTime.Visible = true;
Run Code Online (Sandbox Code Playgroud)
我希望coinRefundCompleteText(它是一个标签)出现4秒钟,然后通过我用clear()定义的方法清除,然后发生其他一些事情.相反,在我用第一个clear()清除我的表单后,我的表单空白4秒,然后正确完成.

那么伙计们,是否可以通过NEXT按钮切换到另一个标签?
这意味着您无法通过单击其他选项卡切换到另一个选项卡页面.
我通常在NEXT按钮上使用的代码是这样的:
tabControl1.SelectedTab = tabPage2;
Run Code Online (Sandbox Code Playgroud) 我已经实现了一个使用TextRenderer.DrawText的CellPainting事件处理程序,它已经很好地工作,直到一个单元格中有一个&符号.单元格在编辑单元格时正确显示&符号,但是在完成编辑并绘制它时,它会显示为一条小线(不是下划线).

using System;
using System.Drawing;
using System.Windows.Forms;
namespace StackOverFlowFormExample {
public partial class DataGridViewImplementation : DataGridView {
public DataGridViewImplementation() {
InitializeComponent();
this.ColumnCount = 1;
this.CellPainting += DGV_CellPainting;
}
private void DGV_CellPainting(object sender, DataGridViewCellPaintingEventArgs e) {
if (!e.Handled && e.RowIndex > -1 && e.Value != null) {
e.PaintBackground(e.CellBounds, false);
TextRenderer.DrawText(e.Graphics, e.Value.ToString(),
e.CellStyle.Font, e.CellBounds,
e.CellStyle.ForeColor, TextFormatFlags.VerticalCenter);
e.Handled = true;
}
}
}
}
//creating the datagridview
public partial class MainForm : Form {
public MainForm() {
InitializeComponent();
DataGridViewImplementation dgvi = new DataGridViewImplementation(); …Run Code Online (Sandbox Code Playgroud) c# ×10
winforms ×10
.net ×4
checkbox ×1
combobox ×1
data-binding ×1
datagridview ×1
linux ×1
report ×1
tabcontrol ×1
timer ×1
unix ×1