我就废话不多说了,大家还是直接看代码吧~
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
|
try { //判断是否可以返回上一视图 if (mapControl.ActiveView.ExtentStack.CanUndo()) { //执行操作 mapControl.ActiveView.ExtentStack.Undo(); //刷新 mapControl.Refresh(); } } catch (Exception ex) { throw ; } |
1
2
3
4
5
6
7
8
9
10
11
12
|
try { if (mapControl.ActiveView.ExtentStack.CanRedo()) { mapControl.ActiveView.ExtentStack.Redo(); mapControl.Refresh(); } } catch (Exception ex) { throw ; } |
补充:C#——单击按钮实现返回上一级窗口方法
一、实现父窗体的隐藏及显现
假设Form1是父窗体,Form2是新的窗体
Form1的按钮button1代码:
1
2
3
4
5
6
7
|
private void button1_Click( object sender, EventArgs e) { Form2 form2 = new Form2( this ); //把form1传给form2 this .Hide(); //把自己隐藏了 //form2.ShowDialog();//2种显示方法都可以 form2.Show(); } |
Form2的代码:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
|
public partial class Form2 : Form { Form1 _form1; public Form2(Form1 form1) { InitializeComponent(); _form1 = form1; } private void button1_Click( object sender, EventArgs e) { //把自己关闭,并显示Form1 this .Close(); _form1.Show(); } } |
二、多线程关闭窗体
Form1 为欢迎界面,close为关闭按钮,Form 2为主界面
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
|
public partial class Form1 : Form { public Form1() { InitializeComponent(); th = new Thread( new ThreadStart(StartNewForm)); } private Thread th; private void StartNewForm() { From1 mf = new From2(); Application.Run(mf); //启动主界面 } private void close_Click( object sender, EventArgs e) { this .Close(); //关闭窗体 th.Start(); //启动另一个线程 } } |
以上为个人经验,希望能给大家一个参考,也希望大家多多支持服务器之家。如有错误或未考虑完全的地方,望不吝赐教。
原文链接:https://blog.csdn.net/qq_38370387/article/details/89187060