问题描述:

I have a grid that I want to pop up in a new window. The code I am using is below. The table is populated with the right data all the way through. The only problem is, when the new winform pops up, it immediately disappears. Also, it's not displaying the data in the grid. I can't figure out what I'm doing wrong. Any ideas?

private void gridView1_ShowGridMenu(object sender, DevExpress.XtraGrid.Views.Grid.GridMenuEventArgs e)

{

GridView view = sender as GridView;

GridHitInfo hitInfo = view.CalcHitInfo(e.Point);

if (hitInfo.InRow)

{

var rowData = gridView1.GetRowCellValue(hitInfo.RowHandle, "SP");

string[] rowDataSplit = rowData.ToString().Split(':');

using (frmInterfaceLogSelection form = new frmInterfaceLogSelection(Services))

{

var sql = rowDataSplit[1].ToString();

var ds = Services.RunSql(sql);

var table = ds.FirstTable();

if (table == null)

{

var error = Services.LastSqlResultError;

if (error.Length > 0)

{

MessageBox.Show(error);

}

return;

}

table.AcceptChanges();

this.gridControl1.DataSource = table;

this.gridView1.Columns.BestFitAll();

form.Show();

}

}

}

网友答案:

It's because you are disposing of the form.

The using statement disposes the form after form.Show(), so it disappears.

You likely need to dispose your SQL connection/service connection, rather than your form.

网友答案:

Try using show dialog

  form.ShowDialog();
相关阅读:
Top