Jay Webster

Jay Webster

  • NA
  • 67
  • 0

Passing variables between forms

Apr 10 2011 6:44 PM
Hi,

I have 2 forms, frmLibrary and frmEdit. I am trying to pass variables from frmLibrary to frmEdit. The variables dont seem to be getting to frmEdit, can someone help? I have the following code:

frmLibrary
        var form = new frmEdit();
        form.Title = ListGrid.SelectedItems[0].Text;
        form.Xexcrc = ListGrid.SelectedItems[0].SubItems[1].Text;
        form.MediaId = ListGrid.SelectedItems[0].SubItems[2].Text;
        form.Wave = ListGrid.SelectedItems[0].SubItems[3].Text;
        form.Burnt = ListGrid.SelectedItems[0].SubItems[4].Text;
        form.Protection = ListGrid.SelectedItems[0].SubItems[5].Text;
        form.Folder = ListGrid.SelectedItems[0].SubItems[6].Text;
        form.Show();


frmEdit
        private string title;
        private string xexcrc;
        private string mediaId;
        private string wave;
        private string burnt;
        private string protection;
        private string folder;

        public string Title
        {
            set { title = value; }
            get { return title; }
        }

        public string Xexcrc
        {
            set { xexcrc = value; }
            get { return xexcrc; }
        }

        public string MediaId
        {
            set { mediaId = value; }
            get { return mediaId; }
        }

        public string Wave
        {
            set { wave = value; }
            get { return wave; }
        }

        public string Burnt
        {
            set { burnt = value; }
            get { return burnt; }
        }

        public string Protection
        {
            set { protection = value; }
            get { return protection; }
        }

        public string Folder
        {
            set { folder = value; }
            get { return folder; }
        }

        public frmEdit()
        {
            InitializeComponent();

            txtTitle.Text = title;
            txtXEXCRC.Text = xexcrc;
            txtMediaID.Text = mediaId;
            txtWave.Text = wave;
            txtBurnt.Text = burnt;
            txtProtection.Text = protection;
            txtFolder.Text = folder;
        }


Answers (2)