从GridEX中的行复制文本

时间:2014-11-07 19:00:27

标签: c# sql-server stored-functions janus gridex

使用Janus GridEx控件,Visual C#。我有一个计时器,通过DB上的存储功能每3分钟更新一次网格。如何双击特定行并将其显示在多行文本框中,并显示网格中4个单元格的文本?

已经在这4天了,我要去坚果!!!

开始表单

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();
    }
}

}

弹出框:

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());
            }
        }
}

}

1 个答案:

答案 0 :(得分:2)

您需要使用GridEX的RowDoubeClick事件。

这是如何使用它:

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();
        }