1、功能:显示在自定义网格的数据。
2、继承层次结构
System.Object
System.MarshalByRefObject
System.ComponentModel.Component
System.Windows.Forms.Control
散或耐System.Windows.Forms.DataGridView
命名空间: System.Windows.Forms
程序集: System.Windows.Forms(在 System.Windows.Forms.dll 中)
3、语法:
C#
[ComplexBindingPropertiesAttribute("DataSource", "DataMember")][ClassInterfaceAttribute(ClassInterfaceType.AutoDispatch)]
[ComVisibleAttribute(true)]
[DockingAttribute(DockingBehavior.Ask)]
public class DataGridView : Control, 冲春
ISupportInitialize
C++
[ComplexBindingPropertiesAttribute(L"DataSource"团散, L"DataMember")][ClassInterfaceAttribute(ClassInterfaceType::AutoDispatch)]
[ComVisibleAttribute(true)]
[DockingAttribute(DockingBehavior::Ask)]
public ref class DataGridView : public Control,
ISupportInitialize
VB
声明<ComplexBindingPropertiesAttribute("DataSource", "DataMember")> _
<ClassInterfaceAttribute(ClassInterfaceType.AutoDispatch)> _
<ComVisibleAttribute(True)> _
<DockingAttribute(DockingBehavior.Ask)> _
Public Class DataGridView _
Inherits Control _
Implements ISupportInitialize
重写控件,开启双缓冲新建类,DoubleBufferListView .cs
/// <summary>
///双毕烂缓冲DataGridView,解决闪烁
/// </summary>
class DoubleBufferListView : DataGridView
{
public DoubleBufferListView()
{
//下面语句为开启双缓冲
SetStyle(ControlStyles.DoubleBuffer | ControlStyles.OptimizedDoubleBuffer | ControlStyles.AllPaintingInWmPaint, true)
UpdateStyles()
}
}
然后点击生成,生成后在工具箱中找到DoubleBufferListView 控件,拖到窗体中键肆,用这个自定义的稿数轿控件就可以了。在用TIMER的时候就不会闪烁了
在窗体里面添加DATAGRIDVIEW在程序里写比如:form_load 或者 page_load 或者button_click
string str="禅樱sever=localhostdatabase=masteruid=sapwd=..." //连接字符串
string _sql="select * from list"//数据库语句
sqldataadapter da=new sqldataadapter(_sql,str)
dataset ds=new dataset()
da.fill(ds,"list"滑源)//list随便叫个信袭态名字都可以,是需拟的DS中的表名
datagridview.datasource=ds.table[0]
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)