Pass (Send) DataGridView selected data from one Form to another using C# and VB.Net in Windows Application

smile
 
on Jun 09, 2021 10:19 PM
474 Views

I have a data like this

ID Doctor     Patient   Room

1   A             SKY       Room-1

2  A             ABC       Room-1   

3   A             SKY       Room-1

i selected the row one to call the patient and it looks like that

Calling to ....

 Doctor is Patient: 1-SkY in Room-1 [this line is giving sound fine]

in the same page calling is working fine.

My Issue is that i want to make this patient call in the next page in the windows form so that patient can view and hear his name in the waiting room display screen.

how to get solution?

how I can send sound in the next page which is being displayed in the next page in datagridview

 my code is 

private void btnPlay_Click(object sender, EventArgs e)
{
    speechSynthesizerObj.Dispose();
    if (richTextBox1.Text != "")
    {
        speechSynthesizerObj = new SpeechSynthesizer();
        //Asynchronously speaks the contents present in RichTextBox1   
        speechSynthesizerObj.SpeakAsync(richTextBox1.Text);
        btnPause.Enabled = true;
        btnStop.Enabled = true;
    }
}

 

private void DisplayData()
{
    con = new SqlDbConnect();
    con.SqlQuery("select Name,StoreType,StoreCode,PID,P_Name,F_Name,Remarks,p.R_Date from tblPatient as p inner join tblCustomer as c on p.CustomerID = c.CustomerID inner join tblStoreType as st on c.StoreTypeID=st.StoreTypeID where p.IsActive='1' order by PID asc;");
    //con.SqlQuery("select PID,P_Name,F_Name,Age,Remarks from tblPatient where IsActive = '1' order by PID asc;");
    paging.SelectCommand = con.Cmd;
    sBuilder = new SqlCommandBuilder(paging);
    ds = new DataSet();
    paging.Fill(ds, "tblPatient");
    sTable = ds.Tables["tblPatient"];
    dGVBrand.DataSource = ds.Tables["tblPatient"].DefaultView;
    lblTotal.Text = dGVBrand.Rows.Count.ToString();
    dGVBrand.ReadOnly = true;
            
    dGVBrand.SelectionMode = DataGridViewSelectionMode.FullRowSelect;
    dGVBrand.Columns[1].DefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleRight;
    dGVBrand.RowsDefaultCellStyle.BackColor = Color.White;
    dGVBrand.AlternatingRowsDefaultCellStyle.BackColor = Color.White;
    dGVBrand.CellBorderStyle = DataGridViewCellBorderStyle.Single;
    dGVBrand.DefaultCellStyle.SelectionBackColor = Color.SteelBlue;
    dGVBrand.DefaultCellStyle.SelectionForeColor = Color.White;
    dGVBrand.DefaultCellStyle.WrapMode = DataGridViewTriState.True;
    dGVBrand.Columns[1].DefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleLeft;

    dGVBrand.SelectionMode = DataGridViewSelectionMode.FullRowSelect;
    dGVBrand.AllowUserToResizeColumns = true;
}

 

private void dGVBrand_CellContentClick(object sender, DataGridViewCellEventArgs e)
{
    richTextBox1.Text = "\tToken Number " + dGVBrand.Rows[e.RowIndex].Cells[3].Value.ToString() + " - \t" + dGVBrand.Rows[e.RowIndex].Cells[4].Value.ToString();
    //richTextBox1.Text = "Token Number:" + dGVBrand.Rows[e.RowIndex].Cells[3].Value.ToString();
    lblID.Text = dGVBrand.Rows[e.RowIndex].Cells[3].Value.ToString();
}

 

Download FREE API for Word, Excel and PDF in ASP.Net: Download
dharmendr
 
on Jun 10, 2021 03:37 AM

Refer below article to send the datagridview row from one form to another. 

Pass (Send) selected DataGridView Row from one Form to another using C# and VB.Net

Then apply the SpeechSynthesizer.