首页 \ 问答 \ 日期格式化WPF数据网格(Date formatting WPF datagrid)

日期格式化WPF数据网格(Date formatting WPF datagrid)

我有一个特殊的问题,首先看起来很容易,但我不知道任何解决方案。 目前我编写了一个C#-WPF-应用程序,可以节省预订。 预订还有一个日期,我从日历中获取。 我将预订保存到我的Sql-Express数据库,日期的值是“DD.MM.YYYY”,数据类型是日期。

现在,我将数据加载到我的应用程序中的数据网格中:

    public DataSet SaveDataToDataSet(DataSet dataset)
    {

        string connectionString = "Data Source=.\\SQLEXPRESS;AttachDbFilename=C:\\Users\\Harald\\Desktop\\Farmer´s Calc\\Programmierung\\WPF\\Finanz_WPF\\Finanz_WPF\\FarmersCalc.mdf;Integrated Security=True;User Instance=True";
        string query = "select bezeichnung 'Bezeichnung', einausgaben 'Einnahmen-Ausgaben',  kostenstelle 'Kostenstelle',  datum 'Buchungsdatum', betrag 'Betrag', details 'Details' from Buchung";
        using (SqlConnection connection =
            new SqlConnection(connectionString))
        {
            SqlDataAdapter adapter = new SqlDataAdapter();
            adapter.SelectCommand = new SqlCommand(
                query, connection);

            adapter.Fill(dataset);
            return dataset;

        }
    }

奇怪的是,DataGrid中的日期列格式为“DD.MM.YYYY HH:MM:SS”,但我只想要“DD.MM.YYYY”! 我需要说的是,我没有定义列,我使用AutoGenerateColumns = true。 有人知道这个解决方案吗?


I´ve got a special problem, that first seems very easy but I don´t know any solution. At the moment I programm a C#-WPF-Application that makes it possible to save bookings. A booking also has a date, which I take from a calender. I save the booking to my Sql-Express Database and the value of a date is "DD.MM.YYYY", the datatype is date.

Now, I load the data into a datagrid in my application:

    public DataSet SaveDataToDataSet(DataSet dataset)
    {

        string connectionString = "Data Source=.\\SQLEXPRESS;AttachDbFilename=C:\\Users\\Harald\\Desktop\\Farmer´s Calc\\Programmierung\\WPF\\Finanz_WPF\\Finanz_WPF\\FarmersCalc.mdf;Integrated Security=True;User Instance=True";
        string query = "select bezeichnung 'Bezeichnung', einausgaben 'Einnahmen-Ausgaben',  kostenstelle 'Kostenstelle',  datum 'Buchungsdatum', betrag 'Betrag', details 'Details' from Buchung";
        using (SqlConnection connection =
            new SqlConnection(connectionString))
        {
            SqlDataAdapter adapter = new SqlDataAdapter();
            adapter.SelectCommand = new SqlCommand(
                query, connection);

            adapter.Fill(dataset);
            return dataset;

        }
    }

Strangely, the date column in the DataGrid has the format "DD.MM.YYYY HH:MM:SS", but I only want "DD.MM.YYYY"! What I need to say is, that I don´t have Columns defined, I make it with AutoGenerateColumns=true. Does anybody know a solution for that?


原文:https://stackoverflow.com/questions/7981447
更新时间:2023-10-31 14:10

最满意答案

如果您希望模拟3270,那么没有选择的缺乏。

  1. 您可以使用Wine和Quick3270模拟器。 我试过这个,它真棒。
  2. 基于Linux:
    一个。 x3270: http ://x3270.bgp.nu/index.html - 尝试过。 它体面和免费(免费在自由)
    湾 Jagacy 3270: http//www.jagacy.com/downloads.html (没有尝试过,但我的同事们使用过它。真的很棒。)

我的爱 - Quick3270在Wine上运行。


If you are looking to emulate 3270 then there is no dearth of choices.

  1. You can use Wine and Quick3270 emulator. I have tried this and its just awesome.
  2. Linux based:
    a. x3270: http://x3270.bgp.nu/index.html - Tried it. Its decent and FREE (free as in Freedom)
    b. Jagacy 3270: http://www.jagacy.com/downloads.html (Haven't tried it, but it was used by my colleagues. Its really good.)

My love - Quick3270 running over Wine.

相关问答

更多
  • 检查session的存放目录是否被其它程序定期不定期的清空, 或者改变目录属性或者做为挂载点挂上了别的东西, 文件系统是否有异常(例如被设置为只读等).
  • 我从来没有尝试过,但Hercules是一个应该在OSX上运行的大型机模拟器。 任何类型的大型机仿真的主要问题是获得您想要的软件。 在现代大型机上运行的软件很少(如果有的话)被授权在仿真器上运行。 如果你提供了一些关于你想要实现的目标的背景知识,那么有人应该能够提出更有帮助的答案。 也就是说,您是在尝试了解架构,学习汇编程序,使用IMS还是使用CICS等? I have never tried, but Hercules is a mainframe emulator that should run on O ...
  • Real VNC服务器4.4包括对Xrandr的支持,可以调整VNC大小。 启动服务器: vncserver -geometry 1600x1200 -randr 1600x1200,1440x900,1024x768 然后调整大小: xrandr -s 1600x1200 xrandr -s 1440x900 xrandr -s 1024x768 Real VNC server 4.4 includes support for Xrandr, which allows resizing the VNC ...
  • 如果您正在CICS中测试应用程序,那么应该可以在自CICS TS V5.1以来的WebSphere Liberty Profile中运行JUnit框架(请参阅https://www-01.ibm.com/support/knowledgecenter/#!/SSGMCP_5 .2.0 / com.ibm.cics.ts.java.doc / topics / liberty_overview.html?cp = SSGMCP_5.2.0%2F5-3-2 )。 测试用例可以使用包含LINK的JCICS API ...
  • 如果您希望模拟3270,那么没有选择的缺乏。 您可以使用Wine和Quick3270模拟器。 我试过这个,它真棒。 基于Linux: 一个。 x3270: http ://x3270.bgp.nu/index.html - 尝试过。 它体面和免费(免费在自由) 湾 Jagacy 3270: http : //www.jagacy.com/downloads.html (没有尝试过,但我的同事们使用过它。真的很棒。) 我的爱 - Quick3270在Wine上运行。 If you are looking to ...
  • $mainframe对象最终是JApplication类的一个实例。 JApplication类在libraries/joomla/application/application.php 。 根据您是否在Joomla的管理员或前端部分, $mainframe对象分别是JAdministrator或JSite的直接实例。 这些类位于includes/application.php和administrator/includes/application.php 。 The $mainframe object is ...
  • 首先,我不确定是否有办法直接从Cobol调用Web服务,但是我们在尝试使用RPG和CL从iSeries(AS400)调用Web服务时遇到了类似的问题。 最后,我们在java中编写了一个简单的Socket程序,在服务器上运行,我们称之为WebServiceBridge,而桥接程序只是从套接字程序中获取数据并用Java构建一个webservice调用。 结果我们简单地通过套接字传回。 如果Cobol与Web服务斗争,那么这可能是一个简单的解决方案。 但请注意,您的网桥需要受到监控,具有弹性,并且始终可以像设计W ...
  • 简短的答案是否定的,它们是不同的东西,但处理登录会话的进程应该处理它们。 PAM会话是libpam内部的概念。 简而言之,当使用PAM的应用程序启动时,它会调用pam_start ,然后调用一个或多个PAM函数,而这些函数又由libpam调度到PAM模块。 其中两个调用是pam_open_session和pam_close_session 。 PAM会话的目标是处理(通常是交互式的,但不一定是)登录会话的设置和拆除。 因此,在会话组中配置的PAM模块通常会执行诸如将用户添加到utmp,设置任何每个登录环境( ...

相关文章

更多

最新问答

更多
  • 获取MVC 4使用的DisplayMode后缀(Get the DisplayMode Suffix being used by MVC 4)
  • 如何通过引用返回对象?(How is returning an object by reference possible?)
  • 矩阵如何存储在内存中?(How are matrices stored in memory?)
  • 每个请求的Java新会话?(Java New Session For Each Request?)
  • css:浮动div中重叠的标题h1(css: overlapping headlines h1 in floated divs)
  • 无论图像如何,Caffe预测同一类(Caffe predicts same class regardless of image)
  • xcode语法颜色编码解释?(xcode syntax color coding explained?)
  • 在Access 2010 Runtime中使用Office 2000校对工具(Use Office 2000 proofing tools in Access 2010 Runtime)
  • 从单独的Web主机将图像传输到服务器上(Getting images onto server from separate web host)
  • 从旧版本复制文件并保留它们(旧/新版本)(Copy a file from old revision and keep both of them (old / new revision))
  • 西安哪有PLC可控制编程的培训
  • 在Entity Framework中选择基类(Select base class in Entity Framework)
  • 在Android中出现错误“数据集和渲染器应该不为null,并且应该具有相同数量的系列”(Error “Dataset and renderer should be not null and should have the same number of series” in Android)
  • 电脑二级VF有什么用
  • Datamapper Ruby如何添加Hook方法(Datamapper Ruby How to add Hook Method)
  • 金华英语角.
  • 手机软件如何制作
  • 用于Android webview中图像保存的上下文菜单(Context Menu for Image Saving in an Android webview)
  • 注意:未定义的偏移量:PHP(Notice: Undefined offset: PHP)
  • 如何读R中的大数据集[复制](How to read large dataset in R [duplicate])
  • Unity 5 Heighmap与地形宽度/地形长度的分辨率关系?(Unity 5 Heighmap Resolution relationship to terrain width / terrain length?)
  • 如何通知PipedOutputStream线程写入最后一个字节的PipedInputStream线程?(How to notify PipedInputStream thread that PipedOutputStream thread has written last byte?)
  • python的访问器方法有哪些
  • DeviceNetworkInformation:哪个是哪个?(DeviceNetworkInformation: Which is which?)
  • 在Ruby中对组合进行排序(Sorting a combination in Ruby)
  • 网站开发的流程?
  • 使用Zend Framework 2中的JOIN sql检索数据(Retrieve data using JOIN sql in Zend Framework 2)
  • 条带格式类型格式模式编号无法正常工作(Stripes format type format pattern number not working properly)
  • 透明度错误IE11(Transparency bug IE11)
  • linux的基本操作命令。。。