我有以下代码:
public class OurTextBox : TextBox
{
public OurTextBox()
: base()
{
this.SetStyle(ControlStyles.UserPaint, true);
}
protected override void OnPaint(PaintEventArgs e)
{
base.OnPaint(e);
Pen penBorder = new Pen(Color.Gray, 1);
Rectangle rectBorder = new Rectangle(e.ClipRectangle.X, e.ClipRectangle.Y, e.ClipRectangle.Width - 1, e.ClipRectangle.Height - 1);
e.Graphics.DrawRectangle(penBorder, rectBorder);
}
}
Run Code Online (Sandbox Code Playgroud)
这是完美的,但它没有显示文本,直到它得到焦点.
有谁能够帮我?怎么了?
预先感谢.
有什么可能的方法来更改日历控件的宽度和高度。我想更改日历的宽度和高度。当我在Google上找到Google时,执行以下步骤:1)在面板中放置月份日历,并允许添加true。并增加面板尺寸。对我不起作用。2)将月历日历放到组框中并停靠。这个月会显示很多个月。3)增加日历控件的字体大小,对我不起作用。
有什么办法可以做到这一点。预先感谢您的评论
我认为问题很简单明确。下面的图像是我当前的进度。
如您所见,自定义版本是我扩展的DateTimePicker控件。控件根据“聚焦”值更改按钮和边框颜色。日历下拉列表是我接下来要设置的样式。
我只是不知道从哪里开始,因为什么都无法工作。我至少不会改变边框颜色,字体颜色等。
我对 C# 很陌生,有一个问题。我已经能够通过将 FlatStyle 更改为“Flat”来更改按钮的边框颜色等。使用NumericUpDown,我无法更改 FlatStyle。我希望仍然能够使用向上和向下箭头,因此仅使用其他东西来覆盖边缘是行不通的。这是我在代码中所做的事情的简化版本:
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace bordertest
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void button1_Click(object sender, EventArgs e)
{
BackColor = Color.Black;
numericUpDown1.BackColor = Color.Red;
}
}
}
Run Code Online (Sandbox Code Playgroud)