Image in PictureBox wird nicht gestretcht



  • Hi,

    ich habe eine PictureBox:

    // 
    			// pictureBox1
    			// 
    			this->pictureBox1->BackgroundImageLayout = System::Windows::Forms::ImageLayout::Stretch;
    			this->pictureBox1->BorderStyle = System::Windows::Forms::BorderStyle::FixedSingle;
    			this->pictureBox1->Location = System::Drawing::Point(118, 42);
    			this->pictureBox1->Name = L"pictureBox1";
    			this->pictureBox1->Size = System::Drawing::Size(80, 40);
    			this->pictureBox1->TabIndex = 2;
    			this->pictureBox1->TabStop = false;
    

    und möchte ein ihr ein Bild zuweisen:

    // Bild hochladen
    private:System::Void button1_Click(System::Object^  sender, System::EventArgs^  e)
    		{
    			try
    			{
    				if (openFileDialog1->ShowDialog() == System::Windows::Forms::DialogResult::OK)
    				{
    					Bitmap^ image1;
    					image1 = gcnew Bitmap(openFileDialog1->FileName);
    					this->pictureBox1->Image = image1;
    				}
    			}
    			catch ( ArgumentException^ )
    			{
    				MessageBox::Show("Fehler beim laden des Bitmaps", "Error!");
    			}
    
    		}
    

    Das Bild wird auch angezeigt, aber es wird nicht gestretcht.
    So das das Bild nicht komplett zu sehen ist.
    Kann mir jemand sagen warum das so ist?



  • du musst die Eigenschaft "SizeMode" der PictureBox auf "PictureBoxSizeMode::StretchImage" setzen.

    Dann müsste es gehen



  • Hat funktioniert!!
    Ich danke dir sehr!


Anmelden zum Antworten