我正在使用DataGridView和对象数据绑定来显示有关系统中日志实体的信息,这些信息是通过SOAP从远程服务中检索的。 其中一列称为“Last action”,表示实体最后一次记录消息。这是一个System.DateTime
值。当我读到SOAP响应(下面的例子)时,他的时间戳显然包含了所有的信息,直到第二部分。如何在DataGridView中格式化DateTime列?
<LoggingEntity>
<host>marty86ce</host>
<process>10148</process>
<logger>http_core</logger>
<appName>httpd</appName>
<ffda>true</ffda>
<lastAction>2010-10-27T12:00:19.5117509Z</lastAction>
<lastHeartbeat>0001-01-01T00:00:00</lastHeartbeat>
<channelId>em_9BA2A2B4D0B6E66</channelId>
<ffdaChannelId>em_E7C8D1D4DE8EEB9</ffdaChannelId>
</LoggingEntity>
当我在表格中显示的话,我反而可以读取高达分钟 我用下面的代码做数据绑定当我按下刷新按钮
public void RefreshEntities()
{
IEntityManagement management = EntityPlugin.GetProxy();
LoggingEntity[] result = management.FindLoggingEntities(new TemplateQuery { ffdaSpecified = true, ffda = true }); //Remote invocation
Invoke(new MethodInvoker(delegate { gridEntities.DataSource = result; })); //THIS does the data binding from the array
Invoke(new MethodInvoker(delegate { btnRefresh.Enabled = true; }));
}
我想知道如何控制数据绑定值的列格式。我认为格式dd/MM/yyyy hh:mm来自我的系统设置。 如何以编程方式覆盖格式设置?
预先感谢您对Subversion(FFDAGui程序)
完整的解决方案代号为Logbus-ng的开源项目。
如何在WPF中做到这一点? – 2017-02-17 06:19:23