Search code examples
c#sql-serverstored-functionsjanusgridex

Copy text from row in GridEX


Using Janus GridEx control, Visual C#. I have a timer that updates the grid every 3 min through a stored function on the DB. How can I double click a specific row and have it show within a multiple line textbox with the text of the 4 cells in the grid?

Been at this for 4 days and am going NUTS!!!

Starting form:

public DSC_Mon()
    {
        InitializeComponent();
        Caller = new DSCU_SvcConsumer.MTCaller();
        dsZA = new DataSet();
        dsOut = new DataSet();
        this.gridEXMon.DoubleClick += new System.EventHandler(this.gridEXMon_DoubleClick);
    }

    private void DSC_Mon_Load(object sender, EventArgs e)
    {
        timer1.Enabled = true;
    }

    private void LoadData()
    {
        if (!dsZA.Tables.Contains("Query"))
        {
            DataTable dtZA = dsZA.Tables.Add("Query");
            dtZA.Columns.Add("str");
            dtZA.Rows.Add(string.Format(@"exec MON_GetStatus"));
        }
        //dtZA.Rows.Add(string.Format(@"select * from am_company"));

        dsOut.Clear();
        dsOut.Merge(Caller.CallRequest("ZuluAction", dsZA));
        if (gridEXMon.DataSource == null)
        {
            gridEXMon.DataSource = dsOut;
            gridEXMon.DataMember = "Table";
        }
        //gridEXMon.RetrieveStructure();
    }

    private void timer1_Tick(object sender, EventArgs e)
    {
        timer1.Enabled = false;
        LoadData();
        timer1.Enabled = true;
    }

    private void gridEXMon_DoubleClick(object sender, EventArgs e)
    {
        ReportInfo report = new ReportInfo();
        report.ShowDialog();
    }
}

}

Popup Box:

public ReportInfo()
    {
        InitializeComponent();
    }

    private void button1_Click(object sender, EventArgs e)
        {
            try
            {
                string value = "System:  " + Environment.NewLine + systemNameTextBox.Text + Environment.NewLine +
                    Environment.NewLine + "Manager:  " + Environment.NewLine + contactName1TextBox.Text +
                    Environment.NewLine + Environment.NewLine + "Function Name:  " + Environment.NewLine +
                    functionNameTextBox.Text;

                Clipboard.SetText(value);

                MailMessage mail = new MailMessage();
                SmtpClient SmtpServer = new SmtpClient("smtpaddress");

                mail.From = new MailAddress("emailaddress");
                mail.To.Add("emailaddress");
                mail.Subject = "Test Mail";
                mail.Body = value;

                SmtpServer.Port = 25;
                SmtpServer.Credentials = new System.Net.NetworkCredential("username", "password");
                SmtpServer.EnableSsl = false;

                SmtpServer.Send(mail);
                MessageBox.Show("       Report Information sent to Service Support Group");
            }

            catch (Exception ex)
            {
                MessageBox.Show(ex.ToString());
            }
        }
}

}


Solution

  • You need to use the RowDoubeClick event of the GridEX.

    This is how to use it:

    private void gridEXMon_RowDoubleClick(object sender, Janus.Windows.GridEX.RowActionEventArgs e)
            {
                if (e.Row.RowIndex < 0)
                    return;
    
                int BillID = Convert.ToInt32(e.Row.Cells["Cell1"].Value);
                String BillID = Convert.ToString(e.Row.Cells["Cell2"].Value);
                Decimal BillID = Convert.ToDecimal(e.Row.Cells["Cell3"].Value);
                int BillID = Convert.ToInt32(e.Row.Cells["Cell4"].Value);
    
                ReportInfo report = new ReportInfo();
                // Here you need to pass the 4 cell values to your Pop up Dialog
                report.ShowDialog();
            }