- android - 多次调用 OnPrimaryClipChangedListener
- android - 无法更新 RecyclerView 中的 TextView 字段
- android.database.CursorIndexOutOfBoundsException : Index 0 requested, 光标大小为 0
- android - 使用 AppCompat 时,我们是否需要明确指定其 UI 组件(Spinner、EditText)颜色
我有一个选项卡控件并在我使用的选项卡标题中放置一个关闭按钮:
private void systemRecordTabControl_DrawItem_1(object sender, DrawItemEventArgs e)
{
e.Graphics.DrawImage(Properties.Resources.icon, e.Bounds.Right - 15, e.Bounds.Top + 3, 11, 11);
e.Graphics.DrawString(systemRecordTabControl.TabPages[e.Index].Text, new Font("Arial", 12, FontStyle.Underline), Brushes.Black, e.Bounds.Left + 12, e.Bounds.Top + 4);
e.DrawFocusRectangle();
}
当程序运行时,每次我在选项卡之间切换时,标题文本会再次绘制在当前选项卡文本的顶部,这导致它非常眼睛酸
例子:
对比
无论如何我可以阻止这种情况发生吗?我不知道如何检查它是否已经绘制
编辑:作为旁注,只有当我将标签页外观设置为“按钮”而 DrawMode 属性为“OwnerDrawFixed”时,才会发生这种情况,同时将焦点更改到另一个控件会导致当前选定的标签页恢复正常(没有文字重叠)
最佳答案
只需重新绘制背景:
private void systemRecordTabControl_DrawItem_1(object sender, DrawItemEventArgs e)
{
e.DrawBackground(); //<-- Redraw background
e.Graphics.DrawImage(Properties.Resources.icon, e.Bounds.Right - 15, e.Bounds.Top + 3, 11, 11);
e.Graphics.DrawString(systemRecordTabControl.TabPages[e.Index].Text, new Font("Arial", 12, FontStyle.Underline), Brushes.Black, e.Bounds.Left + 12, e.Bounds.Top + 4);
e.DrawFocusRectangle();
}
关于每次更改标签页时都会调用 C# WinForm DrawItem,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/49662601/
我有一个选项卡控件并在我使用的选项卡标题中放置一个关闭按钮: private void systemRecordTabControl_DrawItem_1(object sender, DrawIte
我想覆盖 ListBox 的 DrawItem 函数,但失败了。我尝试了来自网络和 msdn 的各种片段,但不知何故它不起作用。 源代码仅用于测试,所以我不关心良好的结构等。我想要一个我可以从中学习并
我更改了各种控件的突出显示颜色,并且我计划进行更多更改。因此,我最好创建自己的控件并重用它们,而不是对每个控件进行更改。 我创建了一个新的用户控件,并继承自System.Windows.Forms.C
我正在编写一个 DrawItem 覆盖方法来修改应用程序,以便 ComboBox DropDowns 中的文本全部居中使用 pDC->DrawText 函数解析 DT_SINGLELINE|DT_VC
如果我创建一个继承自 CButton 的新按钮类,指定 BS_OWNERDRAW 样式,并覆盖 DrawItem 方法,我就可以控制渲染按钮,像这样: void CMyButton::DrawItem
我不确定我的列表框,我创建了一个带有项目的列表框,当我上下滚动时没问题,但是当我另外绘制项目图像(图像+项目名称)时,我看到了带有项目名称的图像, 但上下滚动时有问题。 有什么问题吗? 最佳答案 您是
我正在尝试绘制以红色 * 字符结尾的项目(并删除该 * 字符)并以黑色绘制其他项目。 这是我的代码: private void listBox1_DrawItem(object sender,
我需要自定义 QGraphicsView 的绘制过程,所以我重写了 drawItems 方法,如下所示: self.graphicsview.drawItems=self.drawer.drawIte
嘿,我一直在尝试绘制自己的 TabControl 以摆脱 3D 阴影,但我没有取得太大的成功。 DrawItem 事件目前未触发。必须自己拍吗?我该怎么做? 代码: namespace NCPad {
这是一个 C# 桌面应用程序。我的 ListBox 的 DrawStyle 属性设置为 OwnerDrawFixed。 问题:我重写了 DrawItem 以用不同的字体绘制文本,它起作用了。但是,当我
启用列的自动调整大小并为 ListView 启用OwnerDraw。然后在下面添加代码from HERE : procedure TForm1.ListView1DrawItem(Sender: TC
我正在尝试将 KML 文件导入传单并使其可编辑以供传单绘制。我正在使用 leaflet-omnivore 导入 KML。 var kmlFile = omnivore.kml('Point.kml'
我希望我的 ListView 的选定项在失去焦点时保持清晰可见(它在 Windows 7 上是暗灰色)。我确实将 HideSelection 属性设置为 False。 我想为 ListView 做一些
问题在代码中。无法理解为什么会这样。 private void listView_DrawItem(object sender, DrawListViewItemEventArgs e) {
我在我的 WinForms 应用程序中使用 OwnerDrawFixed 作为自定义 ListBox 控件的 DrawMode。 我想在用户将鼠标悬停在列表框项上时重新绘制 ListBoxItem 的
请考虑以下事项: 我使用以下方法填充我的组合框: void populateComboBox() { comboBox1.DataSource = GetDataTableSource();
我正在自定义 OnDrawItem 事件以在项目名称旁边绘制图标。这是迄今为止我的 OnDrawItem 事件代码: void __fastcall Form1::ComboBox1DrawItem(
我是一名优秀的程序员,十分优秀!