我正在使用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