首页 > 解决方案 > 具有 autogeneratecolumns 的 DataGrid 中的列名显示错误

问题描述

我正在编写一个 WPF 应用程序,它应该从 ORACLE 检索数据并使用 autogeneratecolumns 在 DataGrid 中显示它。问题是某些列名被简单地歪曲了。示例而不是 INITIATE_DATE 仅显示 INITIATEDATE。主要是下划线被忽略。谢谢您的帮助。

<Window x:Class="OPEN_ORDERS_ORACLE_TABLE.MainWindow"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xml:lang="de-DE"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
    xmlns:local="clr-namespace:OPEN_ORDERS_ORACLE_TABLE"
    mc:Ignorable="d"
    Title="MainWindow" Height="450" Width="800" Loaded="Window_Loaded">
    <Grid Height="419" VerticalAlignment="Top">
        <DataGrid x:Name ="DataGrid1" ItemsSource="{Binding}" Margin="10,40,10,70"/>
    </Grid>
</Window>

private void Window_Loaded(object sender, RoutedEventArgs e)
{
    try
    {
        String connectionString = "Data Source=DWH; User Id=readonly; Password=*********;";
        OracleConnection con = new OracleConnection();
        con.ConnectionString = connectionString;
        con.Open();
        OracleCommand cmd = con.CreateCommand();
        cmd.CommandText = "SELECT * FROM AFTERSALES.TBL_OPEN_ORDERS";
        cmd.CommandType = CommandType.Text;
        OracleDataReader dr = cmd.ExecuteReader();
        DataTable dt = new DataTable();
        dt.Load(dr);
        DataGrid1.ItemsSource = dt.DefaultView;
        dr.Close();
        con.Close();
    }
    catch (Exception ex)
    {
        MessageBox.Show(ex.ToString());
    }
}

标签: c#wpforacledatagrid

解决方案


推荐阅读