如何在不使用网格刷新的情况下向DataGridView添加图像框图像?

发布于 2025-02-03 03:17:58 字数 1158 浏览 3 评论 0原文

因此,我正在尝试将picturebox映像添加到DataGridView,而无需使用DataGridView的刷新方法,而没有SQL干预 因此,只需在DataGridView中添加一个picturebox映像,这就是我已经设法按了一行,该行中显示了datagridview外显示的图片框图像 现在我需要相反:我需要一些简单明了的东西 字符串tenthcolumn = picturebox2.image;

        private void AddARow(DataTable table)
    {
        // Use the NewRow method to create a DataRow with 
        // the table's schema.
        // Add the row to the rows collection.
        string firstColum = textBox1.Text;
        string secondColum = textBox2.Text;
        string thirdColum = textBox3.Text;
        string fourthColum = textBox4.Text;
        string dateColum = dateTimePicker1.Value.ToShortDateString();
        string fifthColum = comboBox2.Text;
        string sixthColum = comboBox3.Text;
        string seventhColumn = comboBox4.Text;
        string eighthColumn = comboBox5.Text;
        string ninethcolumn = textBox5.Text;
        
        string tenthcolumn = pictureBox2.Image;//this

        string[] row = { firstColum, secondColum, thirdColum, fourthColum, dateColum, fifthColum, sixthColum,seventhColumn,eighthColumn,ninethcolumn,tenthcolumn  };

        table.Rows.Add(row);
    }

So i'm trying to add an picturebox image to datagridview without having a refresh method of my datagridview and without sql intervention
so just add a picturebox image in a datagridview thats it, i already managed to press in a row and that picture box image that is in the row shows in a picturebox outside the datagridview
now i need the opposite : i need something simple and clear like
string tenthcolumn = pictureBox2.Image;

        private void AddARow(DataTable table)
    {
        // Use the NewRow method to create a DataRow with 
        // the table's schema.
        // Add the row to the rows collection.
        string firstColum = textBox1.Text;
        string secondColum = textBox2.Text;
        string thirdColum = textBox3.Text;
        string fourthColum = textBox4.Text;
        string dateColum = dateTimePicker1.Value.ToShortDateString();
        string fifthColum = comboBox2.Text;
        string sixthColum = comboBox3.Text;
        string seventhColumn = comboBox4.Text;
        string eighthColumn = comboBox5.Text;
        string ninethcolumn = textBox5.Text;
        
        string tenthcolumn = pictureBox2.Image;//this

        string[] row = { firstColum, secondColum, thirdColum, fourthColum, dateColum, fifthColum, sixthColum,seventhColumn,eighthColumn,ninethcolumn,tenthcolumn  };

        table.Rows.Add(row);
    }

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

吾家有女初长成 2025-02-10 03:17:58

我在问一个问题的同时发现了我使用数据表的方式:
使用System.io添加;

        private void AddARow(DataTable table)
    {
        // Use the NewRow method to create a DataRow with 
        // the table's schema.
        // Add the row to the rows collection.
        string firstColum = textBox1.Text;
        string secondColum = textBox2.Text;
        string thirdColum = textBox3.Text;
        string fourthColum = textBox4.Text;
        string dateColum = dateTimePicker1.Value.ToShortDateString();
        string fifthColum = comboBox2.Text;
        string sixthColum = comboBox3.Text;
        string seventhColumn = comboBox4.Text;
        string eighthColumn = comboBox5.Text;
        string ninethcolumn = textBox5.Text;
        //string tenthcolumn = pictureBox2.Image;

        MemoryStream ms = new MemoryStream();
        pictureBox2.Image.Save(ms,pictureBox2.Image.RawFormat);
        byte[] tenthcolumn = ms.ToArray();

        table.Rows.Add(firstColum, secondColum, thirdColum, fourthColum, dateColum, fifthColum, sixthColum, seventhColumn, eighthColumn, ninethcolumn, tenthcolumn);

i found while asking the question lol, by the way i was using a datatable :
add using system.io;

        private void AddARow(DataTable table)
    {
        // Use the NewRow method to create a DataRow with 
        // the table's schema.
        // Add the row to the rows collection.
        string firstColum = textBox1.Text;
        string secondColum = textBox2.Text;
        string thirdColum = textBox3.Text;
        string fourthColum = textBox4.Text;
        string dateColum = dateTimePicker1.Value.ToShortDateString();
        string fifthColum = comboBox2.Text;
        string sixthColum = comboBox3.Text;
        string seventhColumn = comboBox4.Text;
        string eighthColumn = comboBox5.Text;
        string ninethcolumn = textBox5.Text;
        //string tenthcolumn = pictureBox2.Image;

        MemoryStream ms = new MemoryStream();
        pictureBox2.Image.Save(ms,pictureBox2.Image.RawFormat);
        byte[] tenthcolumn = ms.ToArray();

        table.Rows.Add(firstColum, secondColum, thirdColum, fourthColum, dateColum, fifthColum, sixthColum, seventhColumn, eighthColumn, ninethcolumn, tenthcolumn);
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文