我的功能是從選定的文件夾中加載圖片。現在我想通過以新形式打開ZoomLogo來縮放此圖片。在這種新形式中,我想從我的主窗體中'獲取'fullPath1,然後使用ZoomLogo窗體中的此路徑加載圖片。如何做到這一點?如何在C#中從一種表單獲取數據到另一種表單#
void Picture()
{
...
if (DataBaseSelection.SelectedIndex+1==1)
{
Logo1_pictureBox.Image=new Bitmap(@"Logos\\aa.bmp");
var file1 = Path.ChangeExtension(Printer2_TextBox.Text, ".jpg");
var fullPath1 = Path.Combine(@"Documents\\Base\\", file1);
if (!File.Exists(fullPath1))
{
MessageBox.Show("No picture!");
}
else
{
Logo_pictureBox.Image = new Bitmap(fullPath1);
}
...
}
打開新的形式:
void ZoomPictureBoxClick(object sender, EventArgs e)
{
ZoomSchematic settings = new ZoomSchematic();
settings.ShowDialog();
}
我試圖用類似的東西在我的主要形式:
void ZoomPictureBoxClick(object sender, EventArgs e)
{
ZoomSchematic settings = new ZoomSchematic(this.fullPath1);
settings.ShowDialog();
}
,但我不知道如何從功能圖像()這個變量..
您是否需要從ZoomSchematic對話框中獲取指定的設置? – 2011-04-16 09:37:20
我需要的是fullPath1,所以我可以使用此位置路徑顯示圖片。 ZoomSchematic對話框只包含1個圖片框。 – Elfoc 2011-04-16 09:39:37