저는 C# 및 Visual Studio를 학습하여 책과 샘플 코드 모두에서 작업하려고합니다.tableLayoutControl 내에서 전체 그림을 표시하는 방법
저는 tis가 매우 훌륭한 질문은 아니라는 것을 알고 있습니다. 그러나 이것이 제가 풀려고하는 문제입니다. 나는 윈도우 폼을 가지고 있으며 tableLayoutPanel에 포함 된 그림 상자에 이미지를 표시해야합니다. 간단한 문제는 내가로드해야하는 이미지가 여러 크기를 가질 수 있으며 할당 된 공간 내에 일반적인 이미지가 완전히 표시되지 않는다는 것입니다. 컨테이너에 맞는 영역 만 표시되고 나머지 이미지는 잘립니다. 이미지 전체를 표시해야하므로 크기를 조정할 필요가 없습니다. autosize 속성을 이미 설정했지만 작동하지 않는 것 같습니다. 여기
form.cs
string imageName = openFileDialog1.FileName; // Get the image name
// Read the image
try
{
img = (Bitmap) Image .FromFile(imageName);
}
catch
{
MessageBox.Show("oooops" , Text, MessageBoxButtons.OK, MessageBoxIcon .Hand);
}
pictureBox1.Image = img; // show the image
및
다음 form.designer.cs에있는 개인 무효의 InitializeComponent()에서 일부 코드 :this.flowLayoutPanel1 = new System.Windows.Forms.FlowLayoutPanel();
...
this.pictureBox1 = new System.Windows.Forms.PictureBox();
...
this.tableLayoutPanel1.Controls.Add(this.pictureBox1, 1, 1);
...
this.tableLayoutPanel1.Controls.Add(this.pictureBox1, 1, 1);
...
this.tableLayoutPanel1.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 9.034863F));
this.tableLayoutPanel1.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 2.388038F));
this.tableLayoutPanel1.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 88.5771F));
this.tableLayoutPanel1.Size = new System.Drawing.Size(784, 762);
...
this.pictureBox1.SizeMode = System.Windows.Forms.PictureBoxSizeMode.AutoSize;
당신에게 방법에 대한 어떤 힌트를 가지고 전체 이미지를 보여 주겠습니까?
슬라이드 바를 사용해도 괜찮 았지만 컨테이너에 autoscroll = true라는 사실을 알지 못해도 아무 일도 일어나지 않고 이미지는 여전히 잘립니다. 어떤 도움
이 질문을 참조하십시오 http://stackoverflow.com/questions/1106339/resize-image-to-fit-in-bounding-box –
나는 크기를 바꾸고 싶지 않다. 영상. 크기를 조정하지 않고 전체 이미지를 표시하려고합니다. – Daniel
그림 상자의 SizeMode 속성을 확대/축소로 설정하십시오. –