gösterimini sağlayacağız. Şekil 1 i inceleyiniz.
Şekil 1
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
namespace WindowsApplication1
{
public partial class Form1 : Form
{
Panel panel1 = new System.Windows.Forms.Panel();
public Form1()
{
InitializeComponent();
this.SuspendLayout();
panel1.AutoScroll = true;
panel1.BackgroundImage = new Bitmap("C:\\pic1.bmp");
panel1.Location = new System.Drawing.Point(13, 13);
panel1.Size = new System.Drawing.Size(267, 243);
AutoScaleDimensions = new System.Drawing.SizeF(8F, 16F);
AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
ClientSize = new System.Drawing.Size(292, 268);
Controls.Add(panel1);
this.Load += new System.EventHandler(this.Form1_Load);
this.ResumeLayout(false); panel1.AutoScrollMinSize = panel1.BackgroundImage.Size;
}
private void Form1_Load(object sender, EventArgs e)
{
int midX = panel1.AutoScrollMinSize.Width / 2;
int midY = panel1.AutoScrollMinSize.Height / 2;
int halfSizeX = panel1.Size.Width / 2;
int halfSizeY = panel1.Size.Height / 2;
int startPosX = midX - halfSizeX;
if (startPosX < 0) startPosX = 0;
int startPosY = midY - halfSizeY;
if (startPosY < 0) startPosY = 0;
panel1.AutoScrollPosition = new Point(startPosX, startPosY);
}
}
}
//Bir sonraki makalede görüşmek üzere. Bahadır ŞAHİN
0 comments:
Yorum Gönder