怎样在datagridview中显示图片???datagridview中怎样修改名称时让它显示成下拉列表框,直接进行选择
解决方案 »
- 求助!C#中关于ComboBox.SelectedIndex的问题
- 采集flash中提交和返回的socket数据~~~~~
- 如何将多个表(父子关系表)绑定到一个DataGrid控件或任何可以绑定的控件呢?(紧急问题,麻烦大家帮忙一下)
- c#,读取xml文件
- 我在看DirectX9 的例的时候,源程序不能正常运行,提示TextureState,Sampler没有引用.我找遍了也没找到它们是哪个命名空间下的类.谁知道啊?
- MFC真的过时了吗?
- 如何把任意一个小于100的整数,转换成八位,01表示的字符串
- 这里没有"水晶报表"的高手吗?发两个贴子了也没有人回答!再发一贴!up 有分,问题简单!
- 接口 事件 的实现问题
- 急,不能调试,请大虾帮帮忙
- 请教一个XML注释的问题
- 一个简单的计算器程序,为什么不显示结果呢?
{
string picPath = @"....";
System.IO.FileStream fs = new System.IO.FileStream(picPath, System.IO.FileMode.Open);
Image im = Image.FromStream(fs);
fs.Close();
if (e.ColumnIndex == 0)
{
e.Value = im;
}
}
路径这里有点不太明白啊,可以详细点不,加载的时候用dataset绑定,那这里的图片路径怎样获取好呢
{
if (e.Control is DataGridViewComboBoxEditingControl && this.DataGridView.CurrentCell.ColumnIndex == 4 && this.DataGridView.CurrentCell.RowIndex != -1)
{
this.DataGridViewComboBox = (DataGridViewComboBoxEditingControl)e.Control;
DataGridViewComboBox.SelectionChangeCommitted += new EventHandler(this.DataGridViewComboBox_SelectionChangeCommitted);
}
} private void DataGridViewComboBox_SelectionChangeCommitted(object sender, EventArgs e)
{
##你要做的事
} private void DataGridView_CellEndEdit(object sender, DataGridViewCellEventArgs e)
{
if (this.DataGridViewComboBox != null)
{
DataGridViewComboBox.SelectionChangeCommitted -= new EventHandler(this.DataGridViewComboBox_SelectionChangeCommitted);
this.DataGridViewComboBox = null;
}
}
编辑datagridview时,不需要把 DataGridViewTextBoxColumn 换成DataGridViewComboBoxColumn吧
private void DataGridViewComboBox_SelectionChangeCommitted(object sender, EventArgs e)
{
##你要做的事
}
这是个事件??????
private void dataGridview1_CellFormatting(object sender, DataGridViewCellFormattingEventArgs e)
{
if (dataGridview1.Columns[e.ColumnIndex].Name.Equals("Image"))
{
string path = e.Value.ToString();
e.Value = GetImage(path);
}
}
public System.Drawing.Image GetImage(string path)
{
System.IO.FileStream fs = new System.IO.FileStream(path, System.IO.FileMode.Open);
System.Drawing.Image result = System.Drawing.Image.FromStream(fs); fs.Close(); return result; }
使用DataGridViewImageColumn
DataGridViewImageColumn column = new DataGridViewImageColumn();
dataGridView1.Columns.Add(column);
column.HeaderText = "图片";
column.Image = System.Drawing.Image.FromFile("路径"); private void dataGridView1_EditingControlShowing(object sender,
DataGridViewEditingControlShowingEventArgs e)
{
ComboBox combo = e.Control as ComboBox;
if (combo != null)
{
combo.SelectedIndexChanged +=
new EventHandler(ComboBox_SelectedIndexChanged);
}
}
private void ComboBox_SelectedIndexChanged(object sender, EventArgs e)
{
ComboBox cb=(ComboBox)sender;
}