How to pass a UI from one form to anthor form?

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • LittleDong
    New Member
    • Mar 2012
    • 11

    How to pass a UI from one form to anthor form?

    How to pass a form's UI to anthor form?
    such as a ComboBox or TextBox.

    plus how to pass mixed controls i.e. ComboBox & Label & TextBox ?
    use Dictionary<Cont rols>
    or declare a public form.control variable
  • PsychoCoder
    Recognized Expert Contributor
    • Jul 2010
    • 465

    #2
    I'm sorry but I'm not sure I understand what you're trying to do, can you provide more info/better explanation of what you're looking to do.

    Comment

    • LittleDong
      New Member
      • Mar 2012
      • 11

      #3
      Originally posted by PsychoCoder
      I'm sorry but I'm not sure I understand what you're trying to do, can you provide more info/better explanation of what you're looking to do.
      Hi PsychoCoder,

      Anyway thanks for your reply.
      my question is:
      I'm currently developing under Windows Moblie system.

      There are two WinForms. One is called "Setting" Form and anthor is "ShowList" Form.
      Setting Form has
      a ComboBox for user to choose a GPS MeasureMethod,
      a CheckBox indicates whether he/she is a superuser,
      a Textbox stores user's name,
      and a Next Button.

      ShowList Form has
      a ListView with three columns
      [username, MeasureMethod,a uthority ].

      The workflow is the user first set all controls in Setting Form. then click the "Next" Button to show ShowList Form.
      The ShowList Form will automatically add usename, GPS MeasureMethod and authority to the ListView.


      Code are:
      First, I define a public GetSettingValue in Common.cs

      Code:
      public class Common
      {
       .....
      public static string[] m_setInfo = new string[3];
        public static void GetSettingValue(TextBox tbx, ComboBox cbx, CheckBox Ckx)
      {
         
         setInfo[0]= serName;
         setInfo[1]= cbx.Text;
         setInfo[2]= ckx.Checked.ToString();
         return setInfo
      }
      .....
      }

      then, get the seting infomation in Setting.cs
      Code:
      public partial class  Setting : Form
      {
      ....
      private void Next_Click(object sender, EventArgs e)
      {
       Common.GetSettingValue((TextBox1,ComboBox1,CheckBox1));
      }
      ....
      }
      third,show the seting infomation in ShowList.cs
      Code:
      public partial class  ShowList: Form
      {
      ....
      private void ShowList_Click(object sender, EventArgs e)
      {
      .......
      
         int loopi = listItems.Count;
         string rowValue = new string { Common.m_setInfo[0],Common.m_setInfo[1],Common.m_setInfo[2] };
        ListViewItem item = new ListViewItem(rowValue);
         listtoAdd.Items.Add(item);
      .............       
      
      }
      ....
      }
      althrough the way can get the thing done
      but I think it's not convenient.
      so I'm wondering whether there is a better way or a design pattern to implement the function that I want.
      Last edited by LittleDong; Mar 8 '12, 06:36 AM. Reason: edit the text format and explain the question more detailed

      Comment

      Working...