
C#窗体滚动条问题
Bitmapbmap=newBitmap(1300,900);Graphicsgph=Graphics.FromImage(bmap);我画了一个图长1300高900我的...
Bitmap bmap = new Bitmap(1300, 900);
Graphics gph = Graphics.FromImage(bmap);
我画了一个图 长1300高900
我的窗体必须长高必须是 580,580
但是要让窗体带滚动条怎么弄 高手指点下 展开
Graphics gph = Graphics.FromImage(bmap);
我画了一个图 长1300高900
我的窗体必须长高必须是 580,580
但是要让窗体带滚动条怎么弄 高手指点下 展开
4个回答
展开全部
可以加个PictureBox,然后把图片放到里面.再把窗体的AutoScroll 设成true
Bitmap bmap = new Bitmap(1300, 900);
Graphics gph = Graphics.FromImage(bmap);
gph.DrawLine(new Pen(Color.Blue), 0, 0, 100, 100);
PictureBox pb = new PictureBox();
pb.Image = bmap;
pb.Size = bmap.Size;
this.Controls.Add(pb);
this.AutoScroll = true;
Bitmap bmap = new Bitmap(1300, 900);
Graphics gph = Graphics.FromImage(bmap);
gph.DrawLine(new Pen(Color.Blue), 0, 0, 100, 100);
PictureBox pb = new PictureBox();
pb.Image = bmap;
pb.Size = bmap.Size;
this.Controls.Add(pb);
this.AutoScroll = true;
展开全部
progressbar不是一个滚动条的控件吗,直接用算了.如果你要用LEFT WIDTH来算也可以,可以控制窗体大小啊
在load事件里
this.maxsize=new size(580,580);
this.minsize=new size(580,580);
这样就OK了
在load事件里
this.maxsize=new size(580,580);
this.minsize=new size(580,580);
这样就OK了
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
这个有点麻烦的
加个滚动条,在它的事件里掉用Invalid...方法(方法名忘了~:P)
然后重写OnPaint方法
在方法里根据滚动条的值,在窗体上画一部分图片(具体画哪部分要根据窗体大小和滚动条的值进行计算),造成滚动的效果
在《C#高级编程》上有例子,以前做的,记不清了~
加个滚动条,在它的事件里掉用Invalid...方法(方法名忘了~:P)
然后重写OnPaint方法
在方法里根据滚动条的值,在窗体上画一部分图片(具体画哪部分要根据窗体大小和滚动条的值进行计算),造成滚动的效果
在《C#高级编程》上有例子,以前做的,记不清了~
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
给你个例子,图片名字和窗口尺寸自己换掉
using System;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;
public class Sizer : System.Windows.Forms.Form {
private System.Windows.Forms.PictureBox picCritter;
private System.Windows.Forms.HScrollBar scrSize;
public static void Main(){
Application.Run(new Sizer());
}
public Sizer() {
InitializeComponent();
}
private void InitializeComponent() {
this.picCritter = new System.Windows.Forms.PictureBox();
this.scrSize = new System.Windows.Forms.HScrollBar();
this.SuspendLayout();
this.picCritter.BackColor = System.Drawing.Color.White;
this.picCritter.Image = new Bitmap("winter.jpg");
this.picCritter.Location = new System.Drawing.Point(8, 8);
this.picCritter.Name = "picCritter";
this.picCritter.Size = new System.Drawing.Size(40, 40);
this.picCritter.SizeMode = System.Windows.Forms.PictureBoxSizeMode.StretchImage;
this.picCritter.TabIndex = 0;
this.picCritter.TabStop = false;
this.scrSize.Location = new System.Drawing.Point(16, 248);
this.scrSize.Maximum = 200;
this.scrSize.Minimum = 50;
this.scrSize.Name = "scrSize";
this.scrSize.Size = new System.Drawing.Size(256, 16);
this.scrSize.TabIndex = 1;
this.scrSize.Value = 50;
this.scrSize.Scroll += new System.Windows.Forms.ScrollEventHandler(this.scrSize_Scroll);
this.AutoScaleBaseSize = new System.Drawing.Size(5, 13);
this.ClientSize = new System.Drawing.Size(292, 273);
this.Controls.AddRange(new System.Windows.Forms.Control[] {this.scrSize,
this.picCritter});
this.Name = "Sizer";
this.Text = "Sizer";
this.ResumeLayout(false);
}
private void scrSize_Scroll(object sender, System.Windows.Forms.ScrollEventArgs e) {
picCritter.Size = new Size(scrSize.Value, scrSize.Value);
}
}
using System;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;
public class Sizer : System.Windows.Forms.Form {
private System.Windows.Forms.PictureBox picCritter;
private System.Windows.Forms.HScrollBar scrSize;
public static void Main(){
Application.Run(new Sizer());
}
public Sizer() {
InitializeComponent();
}
private void InitializeComponent() {
this.picCritter = new System.Windows.Forms.PictureBox();
this.scrSize = new System.Windows.Forms.HScrollBar();
this.SuspendLayout();
this.picCritter.BackColor = System.Drawing.Color.White;
this.picCritter.Image = new Bitmap("winter.jpg");
this.picCritter.Location = new System.Drawing.Point(8, 8);
this.picCritter.Name = "picCritter";
this.picCritter.Size = new System.Drawing.Size(40, 40);
this.picCritter.SizeMode = System.Windows.Forms.PictureBoxSizeMode.StretchImage;
this.picCritter.TabIndex = 0;
this.picCritter.TabStop = false;
this.scrSize.Location = new System.Drawing.Point(16, 248);
this.scrSize.Maximum = 200;
this.scrSize.Minimum = 50;
this.scrSize.Name = "scrSize";
this.scrSize.Size = new System.Drawing.Size(256, 16);
this.scrSize.TabIndex = 1;
this.scrSize.Value = 50;
this.scrSize.Scroll += new System.Windows.Forms.ScrollEventHandler(this.scrSize_Scroll);
this.AutoScaleBaseSize = new System.Drawing.Size(5, 13);
this.ClientSize = new System.Drawing.Size(292, 273);
this.Controls.AddRange(new System.Windows.Forms.Control[] {this.scrSize,
this.picCritter});
this.Name = "Sizer";
this.Text = "Sizer";
this.ResumeLayout(false);
}
private void scrSize_Scroll(object sender, System.Windows.Forms.ScrollEventArgs e) {
picCritter.Size = new Size(scrSize.Value, scrSize.Value);
}
}
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询