ShowDialog(WinForm)上的C#System.InvalidOperationException

时间:2019-05-28 20:16:15

标签: c# visual-studio winforms

这是我用于将某些数据导出为ex​​cel的代码:

var sd = new SaveFileDialog { Filter = "Excel File (*.xl)|*.xls" };
if (sd.ShowDialog() == DialogResult.OK)
{
    sw = new FileStream(sd.FileName, FileMode.Create);
    GridEXExporter grdListExporter = new GridEXExporter();
    grdListExporter.IncludeFormatStyle = true;
    grdListExporter.IncludeHeaders = true;
    grdListExporter.GridEX = grid;
    grdListExporter.Export(sw);
}

当我单击导出按钮时,出现以下错误:

Visual Styles-related operation resulted in an error because visual styles are currently disabled in the client area.

我还有另一个空白,使用与我提到的相同的代码,这没有问题!但是对于特定的空缺,我会收到此错误。有人可以帮忙吗?

更新 我在if (sd.ShowDialog() == DialogResult.OK)行出现错误

0 个答案:

没有答案