0

我最近正在使用类型化的 Datagridview 从用户那里获取数据,例如姓名、手机号码和用户图像。用户可以输入姓名和手机号码,但是如何在 Datagridview 中获取图像?以及如何在 Sql server 2008 中存储 Datagridview 图像单元格。

这是我的编码:

private void dataGridViewEx1_CellContentDoubleClick
            (object sender, DataGridViewCellEventArgs e)
    {
        OpenFileDialog Dilg = new OpenFileDialog();
        DialogResult DRR = Dilg.ShowDialog();
        if (DRR == DialogResult.OK)
        {
            if (e.RowIndex != -1)
            {
            dataGridViewEx1.Rows[e.RowIndex].Cells[33].Value =       Image.FromFile(Dilg.FileName);
                dataGridViewEx1.Refresh();
                Application.DoEvents();                 
            }
            else
            {
                XtraMessageBox.Show("Out Of Range", "Information");
            }
        }
        else
        {
            return;
        }
    }

但是在使用此代码加载图像之后。图像在 Datagridview 图像单元格中加载,但名称和移动设备等其他详细信息不会从同一列中删除。

如何在不擦除其他列数据的情况下加载图像?

4

1 回答 1

0

为什么需要将所有数据放在一列中?为什么不只使用单独的列来表示名称、编号和其他。这样你就不用担心这个了。

DataGridView 并不是真的要在一列中保存不同的类型。

于 2013-05-02T07:46:41.500 回答