C# ArcGis Engine二次开发 一个窗口调用另一个窗口的控件 30
比如Mapcontrol1控件是窗口1中的并且有publicvoidbutton1_Click(objectsender,EventArgse){OpenFileDial...
比如 Mapcontrol1控件是窗口1中的 并且有
public void button1_Click(object sender, EventArgs e)
{
OpenFileDialog openFileDialog1 = new OpenFileDialog();
openFileDialog1.Filter = "lyr文件(*.lyr)|*.lyr";
openFileDialog1.InitialDirectory = @"D:\\图层文件";
openFileDialog1.Multiselect = false;
DialogResult pDialogResult = openFileDialog1.ShowDialog();
if (pDialogResult != DialogResult.OK)
return;
string pFileName = openFileDialog1.FileName;
axMapControl1.AddLayerFromFile(pFileName);
axMapControl1.ActiveView.Refresh();
}
按按钮实现了往地图中加载了一个图层。
现在我想在另外一个窗口form中实现一个功能,就是按一个form2中按钮就实现form1中按钮的功能
我是这样的
private void sddata_SelectionChangeCommitted(object sender, EventArgs e)
{
Form1 frm1 = new Form1();
string a = sddata.SelectedItem.ToString();//方法2 选中日期传入字符串a
MessageBox.Show(a);
OpenFileDialog openFileDialog1 = new OpenFileDialog();
openFileDialog1.Filter = "lyr文件(*.lyr)|*.lyr";
openFileDialog1.InitialDirectory = @"D:\\图层文件";
openFileDialog1.Multiselect = false;
DialogResult pDialogResult = openFileDialog1.ShowDialog();
if (pDialogResult != DialogResult.OK)
return;
string pFileName = openFileDialog1.FileName;
frm1.axMapControl1.AddLayerFromFile(pFileName);
frm1.axMapControl1.ActiveView.Refresh();
}
但是不能实现,我是新手,请大神赐教啊 分都了 展开
public void button1_Click(object sender, EventArgs e)
{
OpenFileDialog openFileDialog1 = new OpenFileDialog();
openFileDialog1.Filter = "lyr文件(*.lyr)|*.lyr";
openFileDialog1.InitialDirectory = @"D:\\图层文件";
openFileDialog1.Multiselect = false;
DialogResult pDialogResult = openFileDialog1.ShowDialog();
if (pDialogResult != DialogResult.OK)
return;
string pFileName = openFileDialog1.FileName;
axMapControl1.AddLayerFromFile(pFileName);
axMapControl1.ActiveView.Refresh();
}
按按钮实现了往地图中加载了一个图层。
现在我想在另外一个窗口form中实现一个功能,就是按一个form2中按钮就实现form1中按钮的功能
我是这样的
private void sddata_SelectionChangeCommitted(object sender, EventArgs e)
{
Form1 frm1 = new Form1();
string a = sddata.SelectedItem.ToString();//方法2 选中日期传入字符串a
MessageBox.Show(a);
OpenFileDialog openFileDialog1 = new OpenFileDialog();
openFileDialog1.Filter = "lyr文件(*.lyr)|*.lyr";
openFileDialog1.InitialDirectory = @"D:\\图层文件";
openFileDialog1.Multiselect = false;
DialogResult pDialogResult = openFileDialog1.ShowDialog();
if (pDialogResult != DialogResult.OK)
return;
string pFileName = openFileDialog1.FileName;
frm1.axMapControl1.AddLayerFromFile(pFileName);
frm1.axMapControl1.ActiveView.Refresh();
}
但是不能实现,我是新手,请大神赐教啊 分都了 展开
1个回答
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询