【问题标题】:How can I populate a datagridview from top to bottom, left to right?如何从上到下、从左到右填充 datagridview?
【发布时间】:2015-02-12 01:51:04
【问题描述】:

我在 sql server 中有一个存储图像的表。现在我想将所有这些图像检索到 datagridview。但问题是所有图像都显示在datagridview的单列中。我想在 datagridview 中平均分配图像。目前我正在使用此代码

OdbcConnection con= dbc.openconn();
OdbcDataAdapter da = new OdbcDataAdapter("select itempicture from tblItems", con);
DataTable dataTable = new DataTable();          
da.Fill(dataTable); 
dataGridView1.DataSource = dataTable;
con.Close();              

或 我想为此图像显示一些预定义的列和行 datagridview。 我想在销售点应用程序的前端显示这些图像。任何其他建议将不胜感激。 要么 hwo 将每个图像检索到 datagridview row[0]xcolumn[0] 然后 row[0]xcolumn1 然后 row[0]xcolumn[2]....然后 row1xcolumn[0]... .等等... t

【问题讨论】:

    标签: c# image winforms datagridview


    【解决方案1】:
            foreach (DataGridViewRow row in DataGridView.Rows)
            {
                foreach (DataGridViewCell cell in row.Cells)
                {
                    //cell.
                }
            }
    

    【讨论】:

    • 非常感谢您的回复。如何在每个单元格中显示图像。我有一个有两个行 id 和 pic 的表。我将只显示图片行,它在 datagridview 中平均分布。例如如果我有 13 张图片,那么我需要 4 行和 3 列来填充 datagridview。再次感谢你。
    猜你喜欢
    • 2011-09-25
    • 2012-03-28
    • 2019-03-06
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2021-05-04
    相关资源
    最近更新 更多