Hi there, I hava a Form with 2 UserControls and 1 dialogBox. I want to use the DialogBox to set which UserControl will display on the Form. -UserControlA(a button: buttonToB) Form -UserControlB(a button: buttonToA) -DialogBox(2 buttons: Ok & Cancel) The Form will display UserControlA as StartUp, when buttonToB is clicked, the DialogBox appears, if Ok is pressed, then UserControlA will be removed and UserControlB will be add to the Form. I have public menthods in the Form as follows: public void RemoveUserControlA(){ this.Controls.Remove(UserControlA) // remove B UserControlA.Dispose(); } public void AddUserControlB(){ this.Controls.Add(UserControlB) } In the UserControlA, when the buttonToB is clicked private void buttonToB_click(){ if(dialog.Result == Ok){ Form f = new Form(); f.RemoveUserContorlA(); f.AddUserControlB(); } } Questions 1) How can I have some methods in the Form, and then invoke it in the UserContolA (i.e. public methods ?)? 2) How can I remove the Usercontrols using the dialog? thanks. :)
luckyShek
Posts
-
Quesions in this.Controls.Remove()/Add() ?? -
Open a Project, then close another one??hi there, I have a Solution with two projects. Both projects have a main method to open its own. - projectA - formA(with a main() method) - buttonA Solution - projectB - formB(with a main() method) - buttonB I want to open formB in projectB by clicking buttonA. private void buttonA_click(){ projectB.formB fb = new projectB.formB(); fb.Show(); // open projectB this.Visible = false; // close projectA this.Dispose(); } But," this.Visible = false; and this.Dispose();" statements cause both projects closed. 1) how can Open a Project, then close another one by not using " this.Visible = false; and this.Dispose();" ?? Thansks
-
Renaming .exe file to .dll file ???Thanks
-
Renaming .exe file to .dll file ???hi there, I had created a UserControl.exe. I want to add it to a project by using "Add References". But it only take .dll file. 1) Can I just rename UserControl.exe to UserControl.dll ? 2) Will it cause any error ?? 3) What's the best to create a userControl file with .dll in vs.net ? Thank you very much. ;)
-
Select Top 10 from a DataTable ???Hi! I want to select only 10 rows from a dataTable each time, just as a paging from a database("SELECT TOP 10 FROM orders WHERE ID <100 ORDER BY ID"). for example: DataTable myTable = new DataTable("orders"); DataRow[] rows = myTable.Select("TOP 10 ID < 100"); 1)How can I write the correct statement. 2)Can I ues "TOP" key word or there's other way to do it? Thank you very much.
-
Select Top 10 in a dataTable???Hi! I want to select only 10 rows from a dataTable each time, just as from a database("SELECT TOP 10 FROM orders WHERE ID <100 ORDER BY ID"). for example: DataTable myTable = new DataTable("orders"); DataRow[] rows = myTable.Select("TOP 10 ID < 100"); 1)How can I write the correct statement. 2)Can I ues "TOP" key word or there's other way to do it? Thank you very much.:rose:
-
ListView move Up / Down using Index ??:omg:I have a Form with a ListView and two buttons(Move_Up & Move_Down). I want to reoder the ListView by moving an item up or down by clicking either the button Up / button Down. I get the selected listView item's Index, then use Index + 1 or Index -1 to move the item up / down. The code of move up with Index-1 works. But the code of move down with Index+1 does not work. I don't know why, please help! Thanks! The code is as follows: // this move up works (Index-1) private void btnUp_Click(object sender, System.EventArgs e){ if(listView1.Items.Count != 0){ ListViewItem item = listView1.FocusedItem; if(item != null){ int index = item.Index -1 ListViewItem insert = (ListViewItem) listView1.Items.Insert(index, insert); listView1.Items.Remove(item); } } } // this move down does NOT work (Index +1) private void btnDown_Click(object sender, System.EventArgs e){ if(listView1.Items.Count != 0){ ListViewItem item = listView1.FocusedItem; if(item != null){ int index = item.Index + 1 ListViewItem insert = (ListViewItem) listView1.Items.Insert(index, insert); listView1.Items.Remove(item); } } }