【发布时间】:2010-10-27 12:26:05
【问题描述】:
我正在使用带有对象数据绑定的 DataGridView 来显示有关系统中记录实体的信息,这些信息是通过 SOAP 从远程服务中检索的。
其中一列称为“上次操作”,表示实体上次记录消息的时间。这是一个System.DateTime 值。当我阅读 SOAP 响应(下面的示例)时,他的时间戳显然包含所有信息,最多可达秒。
<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 中做到这一点?
标签: c# winforms data-binding datetime datagridview