Quantcast
Channel: Programming Forums
Viewing all articles
Browse latest Browse all 51036

Passing String From datagridview to textbox in another form

$
0
0
I have set up a 2 forms one loads up a datagridview and the user clicks on the view to select the value they want. I can get the value displaying inside a messagebox on the same form as the datagridview However when i try to pass it across to another form it appears NULL. How would i get it displaying inside the textbox. Here is my code. When i debug the code it first passes across the value correctly but when it finishes running it shows as a null value. I have tried a number of different ways of doing this tried to do it using public variables on the different classes also.

Form one with the TextBox
public void FillTextBoxes(object sender, EventArgs e, string SupplierID)
    {
        supplierVO _SupplierVo = new supplierVO();
        ListOfSuppliers _ListOfSuppliers = new ListOfSuppliers();
        SupplierID = _ListOfSuppliers.SupplierCode;                                   
        MessageBox.Show(SupplierID);
        txtSupplierCode.Text = SupplierID;         
    }


Form2 with the dataGridView

    // Links to the user double click of the datagrid
    public void SelectGridInformation (object sender, EventArgs e)
    {   
        ChangeSupplierInfo _ChangeSupplerInfo = new ChangeSupplierInfo();

        supplierVO _SupplierVO = new supplierVO();

        Int32 selectedRowCount = dataGridView1.Rows.GetRowCount(DataGridViewElementStates.Selected);

        string SelectedSupplierID = dataGridView1.SelectedCells[0].Value.ToString();

        SupplierCode = SelectedSupplierID;

        _SupplierVO.SupplierCode = SelectedSupplierID;

        _ChangeSupplerInfo.FillTextBoxes(sender, e, SelectedSupplierID);

        this.Close();
    }

I have been trying to do this with the Get and Set Property's here is the code sample for this.
public string SupplierCode
    {
        get
        {
            return _SupplierCode;
        }
        set
        {
            _SupplierCode = value;
        }
    }

Viewing all articles
Browse latest Browse all 51036

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>