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