Witam chce zaladowac zdjecia z wybranego katalogu...oczywiscie najlepiej zeby byly one w tabeli wiec probowalem uzyc TableLayoutPanel i jego wlascisco backgroundImage...jednak dostaje blad...
private void otworzKatalogToolStripMenuItem_Click(object sender, System.EventArgs e)
{
ArrayList path = new ArrayList();
string folder;
int filesCount = 0;
float maxRows;
this.folderBrowserDialog1 = new System.Windows.Forms.FolderBrowserDialog();
this.folderBrowserDialog1.ShowNewFolderButton = false;
this.folderBrowserDialog1.RootFolder = System.Environment.SpecialFolder.MyComputer;
DialogResult result = this.folderBrowserDialog1.ShowDialog();
folder = folderBrowserDialog1.SelectedPath;
if (result == DialogResult.OK)
{
foreach (string file in System.IO.Directory.GetFiles(folder))
{
path.Add(file);
filesCount++;
}
//layout
this.tableLayoutPanel1 = new TableLayoutPanel();
this.tableLayoutPanel1.Location = new System.Drawing.Point(0, 27);
this.tableLayoutPanel1.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Absolute, 50F));
this.tableLayoutPanel1.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Absolute, 50F));
this.tableLayoutPanel1.ColumnCount = 3;
maxRows = filesCount / this.tableLayoutPanel1.ColumnCount;
this.tableLayoutPanel1.RowCount = Convert.ToInt32(Math.Round(maxRows));
for(int i = 0; i <= path.Count; i++)
this.tableLayoutPanel1.BackgroundImage = System.Drawing.Image.FromFile(Convert.ToString(path[i])); //tu jest blad out of memory
}
}
A wiec tak mam pare pytan...
Czy dobrze tworze dynamicznie kolumny i wiersze...?
Czy jest to wydajny sposob?Bo poki co nie dziala wiec nie wiem jak szybko dziala...
Jak molgbym dodac do komorek TableLayoutPanel kontrolke picturebox bo wolalbym do niej ladowac zdjecia...
W czym tkwi problem...?