随笔-193  评论-715  文章-1  trackbacks-0

It seems, the DataGrid component is a depreted component.
So I will try to use the DataGridView component.

using  System;
using  System.Collections.Generic;
using  System.ComponentModel;
using  System.Data;
using  System.Drawing;
using  System.Text;
using  System.Windows.Forms;

namespace  CATS
{
    
public  partial  class  QueryResumeForm : Form
    
{

        
private  System.Data.DataTable dt  =   new  System.Data.DataTable();
        DataGrid dataGrid 
=   new  DataGrid();

        
public  QueryResumeForm(CATS.CatsAppForm parent)
        
{
            InitializeComponent();
            
this .MdiParent  =  parent;
            
this .CreateTableStruct();
        }



        
private   void  CreateTableStruct()
        
{
            dt.Columns.Add(
" textbox1 " , System.Type.GetType( " System.String " ));
            dt.Columns.Add(
" textbox2 " , System.Type.GetType( " System.String " ));
            dt.Columns.Add(
" textbox3 " , System.Type.GetType( " System.String " ));
        }



        
private   void  queryButton_Click( object  sender, EventArgs e)
        
{
            System.Data.DataRow dr 
=  dt.NewRow();
            dr[
" textbox1 " =   " a " ;
            dr[
" textbox2 " =   " bb " ;
            dr[
" textbox3 " =   " ccc " ;

            dt.Rows.Add(dr);

            
this .dataGrid.SetDataBinding(dt,  "" );
            
this .dataGrid.Parent  =   this ;

            
this .dataGrid.SetBounds( 10 50 500 300 );
            
this .dataGrid.Show();
        }


    }

}
posted on 2009-01-03 22:40 Robin's Programming World 阅读(503) 评论(0)  编辑  收藏 所属分类: .Net

只有注册用户登录后才能发表评论。


网站导航: