Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>Form has only one panel (<strong>pnlGrid</strong>) and panel's <strong>AutoScroll</strong> property setted as true;</p> <pre><code>DataTable dtImage = new DataTable(); dtImage.Columns.Add("Path"); dtImage.Columns.Add("Name"); dtImage.Rows.Add(new object[] { "ImagePath", "ImageText" }); dtImage.Rows.Add(new object[] { "ImagePath", "ImageText" }); dtImage.Rows.Add(new object[] { "ImagePath", "ImageText" }); CreateImageGrid(dtImage); </code></pre> <p>and method;</p> <pre><code>private void CreateImageGrid(DataTable dtDataSource) { int colCount = 5; int rowCount = 0; int imgWidth = 100; int imgHeight = 100; int imgPadding = 10; int lblPadding = 5; int ind = -1; PictureBox pic = null; Label lbl = null; if (dtDataSource.Rows.Count &gt; colCount) { rowCount = Convert.ToInt32(dtDataSource.Rows.Count / colCount); if (Convert.ToInt32(dtDataSource.Rows.Count % colCount) &gt; 0) { rowCount++; } } else { rowCount = 1; } for (int j = 0; j &lt; rowCount; j++) { for (int i = 0; i &lt; colCount &amp;&amp; dtDataSource.Rows.Count &gt; ((j * colCount) + i); i++) { ind = (j * colCount) + i; pic = new PictureBox(); pic.Image = Image.FromFile(dtDataSource.Rows[ind]["Path"].ToString()); pnlGrid.Controls.Add(pic); pic.Width = imgWidth; pic.Height = imgHeight; pic.Top = (j * (imgHeight + imgPadding)) + imgPadding; pic.Left = (i * (imgWidth + imgPadding)) + imgPadding; lbl = new Label(); lbl.Text = dtDataSource.Rows[ind]["Name"].ToString(); pnlGrid.Controls.Add(lbl); lbl.Left = pic.Left; lbl.Top = pic.Top + pic.Height + lblPadding; } } } </code></pre> <p><em><strong>Note:</strong> Text lengths may cause problems, you should define some rules.</em></p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload