在自定义控件(复合控件)后,有些属性想立即显示到界面上,而不是编译之后才能,显示到界面上,这个时候,应该在控件属性的set操作里面添加相应的函数处理。
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Data;
using System.Linq;
using System.Text;
using System.Windows.Forms;
namespace MyControl
{
public partial class ColorForGridControl : UserControl
{
public ColorForGridControl()
{
InitializeComponent();
DisplayText = "已成交";
}
private string displayText;
public string DisplayText
{
get { return displayText; }
set
{
displayText = value;
this.lblDisplayText.Text = DisplayText;
this.Invalidate();
}
}
private Color color;
public Color Color
{
get { return color; }
set
{
color = value;
this.pnlColor.BackColor = Color;
this.lblDisplayText.ForeColor = Color;
this.Invalidate();
}
}
private void ColorForGridControl_Load(object sender, EventArgs e)
{
if (Color == Color.Empty)
Color = Color.Green;
if (DisplayText == string.Empty)
DisplayText = "已成交";
this.pnlColor.BackColor = Color;
this.lblDisplayText.ForeColor = Color;
this.lblDisplayText.Text = DisplayText;
}
}
}
分享到:
相关推荐
因此,有必要写一个自定义View来实现。 思路如下: 新建一个TextRatingBar继承View类 在onDraw()方法中绘制元素:文字、横线、短竖线和圆形标记 重写onMeasure()方法,控制整体大小和边界 在onTouchEvent()方法...
使日期控件具有更改背景色的属性,在使用时要调用Invalidate()方法
invalidate()的用法 主要用于刷新
串口控件说明: 本程序使用VC6.0的通用串口控件MSCOMM32.OCX来对发送到串口的数据进行采集处理...只要当全局变量中的数值发生变化后就使用函数this->Invalidate()强制重载OnPaint()函数,那么数据图就可以动起来了。
分析invalidate流程例子
三种得到LinearInflater的方法 a. LayoutInflater inflater = getLayoutInflater(); b....(LayoutInflater)context.getSystemService (Context.LAYOUT_INFLATER_SERVICE);...onDraw画完图后,给控件设置点
Invalidate与UpdateWindow区别.doc
后半部分为将图像显示在界面上,实际代码在OnPaint()中。在DisplayPicture()中执行Invalidate()激活OnPaint事件。 显示图像的区域使用了一个VC图像控件的区域,实际可根据自己需要选择在界面所需区域显示。
Invalidate函数及WM_PAINT总结,想必学VC++的都知道这两个东东的作用了!
一个简单的自定义view的实现。设计到paint,自定义属性,invalidate,canvas的使用
vc学习,Invalidate(true),Invalidate(false)2008-08-27 08:13在学一个位图显示程序时,发现了图像显示能不能重绘的问题,当时看了msdn,也在网上看了不少回复。总感觉不是很理解。后来仔细试了一下,有点心得,特写...
Invalidate()函数[参考].pdf
3.2 invalidate()方法 65 3.3 坐标转换 69 3.4 剪切区(Clip) 73 3.5 案例:指针走动的手表 82 3.6 练习作业 88 第四章 双缓存技术 89 4.1 双缓存 89 4.2 在屏幕上绘制曲线 90 4.3 在屏幕上绘制矩形 99 4.4 案例:...
Android提供了Invalidate方法实现界面刷新,但是Invalidate不能直接在线程中调用,因为他是违背了单线程模型:Android UI操作并不是线程安全的,并且这些操作必须在UI线程中调用。 Android程序中可以使用的界面...
CSharp 4.0 .Net Framework V4.0 Control.Invalidate 方法
Android中View绘制流程以及invalidate()等相关方法分析
Android中View控件的Demo,值得学习。实现画多个圆圈的效果。
Android中实现view的更新有两组方法,一组是invalidate,另一组是postInvalidate,其中前者是在UI线程自身中...比如在修改某个view的显示时,调用invalidate()才能看到重新绘制的界面。invalidate()的调用是把之前的旧
新建工程 c# 》智能设备 》控件库 public partial class LED : UserControl { bool isonoff; public LED { InitializeComponent ; isonoff false; } [DefaultValue false Description "状态" ...
android 可移动控件 /** * 用于判断view的移动 * @param view * @param event * @return */ @Override public boolean onTouch(View view, MotionEvent event) { final int X = (int) event.getRawX(); ...