从 GridEX 中的行复制文本
Posted
技术标签:
【中文标题】从 GridEX 中的行复制文本【英文标题】:Copy text from row in GridEX 【发布时间】:2014-11-07 19:00:26 【问题描述】:使用 Janus GridEx 控件,Visual C#。我有一个计时器,它通过数据库上的存储函数每 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】:您需要使用 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();
【讨论】:
以上是关于从 GridEX 中的行复制文本的主要内容,如果未能解决你的问题,请参考以下文章