| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 855 人关注过本帖
标题:[求助]dataGridView的RowNumber和ColumnNumber?????
取消只看楼主 加入收藏
okkenking
Rank: 1
等 级:新手上路
帖 子:111
专家分:0
注 册:2007-5-10
收藏
 问题点数:0 回复次数:0 
[求助]dataGridView的RowNumber和ColumnNumber?????

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

namespace Test
{
public partial class Form4 : Form
{

ComboBox combo = new ComboBox();
DateTimePicker date = new DateTimePicker();
DataSet ds = new DataSet();
public Form4()
{
InitializeComponent();
}

private void Form4_Load(object sender, EventArgs e)
{
OleDbConnection con = new OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" + Application.StartupPath + "\\Users.mdb");
OleDbDataAdapter da = new OleDbDataAdapter("select * from [User]", con);
try
{
da.Fill(ds, "User"); //填充数据集
}
catch (Exception er)
{
MessageBox.Show(er.Message);
}

// combo = new ComboBox(); //实例化combox
combo.Items.Add("男"); //加入内容
combo.Items.Add("女");
combo.Visible = false; //设为不可见
//combo.SelectedIndexChanged += new System.EventHandler(combo_SelectedIndexChanged);//注册委托
//combo.SelectedIndex=0;
this.dataGridView1.Controls.Add(combo); //将combox加入dataGridView控件
//date = new DateTimePicker(); //实例化DataTimePicker控件
date.Value = DateTime.Now; //初始化
//date.ValueChanged += new System.EventHandler(date_ValueChanged); //注册委托
date.Visible = false; //设为不可见
this.dataGridView1.Controls.Add(date); //加入dataGridView控件
this.dataGridView1.DataSource = ds.Tables[0]; //数据绑定
}
private void combo_SelectedIndexChanged(object sender,EventArgs e)
{
dataGridView1[dataGridView1.CurrentCell.RowNumber,dataGridView1.CurrentCell.ColumnNumber]=combo.SelectedItem;
}
private void date_ValueChanged(object sender, EventArgs e)
{
dataGridView1llData[dataGridView1.CurrentCell.RowNumber,dataGridView1.CurrentCell.ColumnNumber]=date.Value.ToShortDateString();
}
}
}

2005的dataGridView无RowNumber和ColumnNumber.

搜索更多相关主题的帖子: using System dataGridView ColumnNumber RowNumber 
2007-06-06 16:12
快速回复:[求助]dataGridView的RowNumber和ColumnNumber?????
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.050213 second(s), 8 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved