请教高手!如何在DATAGRID表格重绘图片!狂谢!分不够再加! 还有除了DATAGRID有没有其它更好的表格控件啊! 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 win的还是web的?2者好象实现的方式不一样的 唉!这样吧!也就是在DataGrid指定的表格中绘制一些图片和控件!比如!让一个下拉式列表在能在表格中显示!我是在Winform下做的! private void button2_Click(object sender, System.EventArgs e) { OleDbCommand dd = m_adoapp.OleConnectionInstance.CreateCommand(); dd.CommandText = "select * from tb_users"; OleDbDataAdapter ad = new OleDbDataAdapter("select * from tb_users",m_adoapp.OleConnectionInstance); ad.Fill(a); DataView dv = new DataView(a); dv.AllowNew = false; this.dataGrid1.DataSource = dv; this.dataGrid1.ReadOnly = true; this.dataGrid1.AlternatingBackColor = System.Drawing.Color.Silver; cbx = new ComboBox(); cbx.Name = "cbx"; cbx.Visible = false; cbx.Items.Clear(); cbx.Items.Add("Sales Representative"); cbx.Items.Add("Inside Sales Coordinator"); cbx.Items.Add("Vice President, Sales"); cbx.Items.Add("Sales Manager"); cbx.Items.Add("Flunky"); cbx.TextChanged += new EventHandler(cbx_TextChanged); this.dataGrid1.Controls.Add(cbx); } private void cbx_TextChanged(object sender, System.EventArgs e) { this.dataGrid1[this.dataGrid1.CurrentCell] = cbx.Text; } private void dataGrid1_CurrentCellChanged(object sender, System.EventArgs e) { if(this.dataGrid1.CurrentCell.RowNumber == 0 && this.dataGrid1.CurrentCell.ColumnNumber == 0) this.dataGrid1.ReadOnly = true; else this.dataGrid1.ReadOnly = false; if( this.dataGrid1.CurrentCell.ColumnNumber == 3) { cbx.Visible = false; cbx.Width = 0; cbx.Left = this.dataGrid1.GetCurrentCellBounds().Left; cbx.Top = this.dataGrid1.GetCurrentCellBounds().Top; cbx.Text = this.dataGrid1[this.dataGrid1.CurrentCell].ToString() ; cbx.Visible = true; } else { cbx.Visible = false; cbx.Width = 0; } } private void dataGrid1_Paint(object sender, System.Windows.Forms.PaintEventArgs e) { if(this.dataGrid1.CurrentCell.ColumnNumber == 3) { cbx.Width = this.dataGrid1.GetCurrentCellBounds().Width; } } private void dataGrid1_Scroll(object sender, System.EventArgs e) { cbx.Visible = false; cbx.Width = 0; } 如何一次向数据库中增加多条记录?-----求解答 C# exe传参运行问题 DropDownList 的问题 如何实现我的电脑里的功能! 怎样动态修改数据表的字段? 为什么总是提示asp.net 不是1.1版本 DATAGRIDVIEW1的单元格里输入数据的同时可以从数据库中获取与之匹配的记录 Treeview 如何写某个节点的右击事件? 读一文本文件到一DataSet? 如何使DataGrid中布尔列的状态只有两种? winform 的datagrid问题! c#中如何取得数组下标
比如!让一个下拉式列表在能在表格中显示!
我是在Winform下做的!
{
OleDbCommand dd = m_adoapp.OleConnectionInstance.CreateCommand();
dd.CommandText = "select * from tb_users"; OleDbDataAdapter ad = new OleDbDataAdapter("select * from tb_users",m_adoapp.OleConnectionInstance);
ad.Fill(a);
DataView dv = new DataView(a);
dv.AllowNew = false;
this.dataGrid1.DataSource = dv;
this.dataGrid1.ReadOnly = true; this.dataGrid1.AlternatingBackColor = System.Drawing.Color.Silver; cbx = new ComboBox();
cbx.Name = "cbx"; cbx.Visible = false; cbx.Items.Clear(); cbx.Items.Add("Sales Representative"); cbx.Items.Add("Inside Sales Coordinator"); cbx.Items.Add("Vice President, Sales"); cbx.Items.Add("Sales Manager"); cbx.Items.Add("Flunky");
cbx.TextChanged += new EventHandler(cbx_TextChanged); this.dataGrid1.Controls.Add(cbx);
} private void cbx_TextChanged(object sender, System.EventArgs e)
{
this.dataGrid1[this.dataGrid1.CurrentCell] = cbx.Text; }
private void dataGrid1_CurrentCellChanged(object sender, System.EventArgs e)
{
if(this.dataGrid1.CurrentCell.RowNumber == 0 && this.dataGrid1.CurrentCell.ColumnNumber == 0)
this.dataGrid1.ReadOnly = true;
else
this.dataGrid1.ReadOnly = false; if( this.dataGrid1.CurrentCell.ColumnNumber == 3)
{ cbx.Visible = false; cbx.Width = 0; cbx.Left = this.dataGrid1.GetCurrentCellBounds().Left; cbx.Top = this.dataGrid1.GetCurrentCellBounds().Top; cbx.Text = this.dataGrid1[this.dataGrid1.CurrentCell].ToString() ; cbx.Visible = true;
}
else
{
cbx.Visible = false; cbx.Width = 0; } } private void dataGrid1_Paint(object sender, System.Windows.Forms.PaintEventArgs e)
{
if(this.dataGrid1.CurrentCell.ColumnNumber == 3)
{
cbx.Width = this.dataGrid1.GetCurrentCellBounds().Width;
} } private void dataGrid1_Scroll(object sender, System.EventArgs e)
{
cbx.Visible = false; cbx.Width = 0;
}