0
嗨程序员, 其实我有3种形式,即mdiparent形式,mdichild和用户控件。 usercontrol窗体有treeview.So我需要从mdichildform刷新usercontrol。我创建了用户控件的实例并激发了事件刷新,但不会发生。有什么建议么。如何从winforms中的其他窗体刷新Usercontrol?
My UserControl code goes like this:
public partial class cHumanResource : UserControl
{
Human_Resource_Utility human_Record = new Human_Resource_Utility();
MyConnection mc = new MyConnection();
TreeNode tn = new TreeNode();
TreeNode tn_dept = new TreeNode();
List<TreeItemInfo> treeViewList = new List<TreeItemInfo>();
private string LoginUser;
private List<FeaturesInfo> UserSettings = new List<FeaturesInfo>();
public cHumanResource()
{
InitializeComponent();
}
public void LoadEmpDetail()
{
tstriptxtSearch.Text = "";
EmployeeSearch("");
TreeLoad.CollapseAll();
Application.DoEvents();
}
}
而像frmchild代码:像
public interface IMdiFormInterface
{
void RemoveActionBar();
void CreateActionButtons(string mode,FeaturesInfo SETTINGS);
void ToggleExplorerBar();
void ToggleExplorerBar(bool Visibility);
}
public interface IChildFormInterface { void CommandPass(string key,FeaturesInfo Settings);}
public partial class frmAttnMain : Form, IMdiFormInterface
{
Attendance.SystemLogin syslogin = new SystemLogin();
Utility_Mode.FileHandlingUtility fileHandling = new Attendance.Utility_Mode.FileHandlingUtility();
string seltext = "100%";
string selgototxt = "1";
private static string CurUser=string.Empty;
private List<FeaturesInfo> menuname =null;
private int totalpage = 0;
FeaturesInfo Fmodel = new FeaturesInfo();
private static frmAttnMain aForm = null;
private static List<FeaturesInfo> aFavmodel;
public static frmAttnMain Instance(string usercode,List<FeaturesInfo> fmodel,string Action)
{
aFavmodel = fmodel;
// aForm.loadDatabase();
CurUser = usercode;
}
你能后的你一些示例代码到目前为止做了什么? – aleroot 2012-03-19 10:08:00
您正在创建一个用户控件的新实例来添加永远不会工作的树,使用您在mdiChild窗体上添加的用户控件的相同实例来重新创建:D – BreakHead 2012-03-19 10:11:10