【问题标题】:binding nested structures to datagridview将嵌套结构绑定到 datagridview
【发布时间】:2011-12-29 03:08:21
【问题描述】:

我有两个结构,其中一个是嵌套的。

Public Structure RetailRpt
    Public FromDate As Date
    Public ToDate As Date
    Public GenDate As Date
    Public RetailId As Integer
    Public TotalSellAmt As Integer
    Public CancelSellAmt As Integer
    Public NetSellAmt As Integer
    Public PayOut As Integer
    Public OperatorBal As Integer
    Public AgentDiscountAmt As Integer
    Public NetToPay As Integer
End Structure
Public Structure DSRpt
    Public FromDate As Date
    Public ToDate As Date
    Public GenDate As Date
    Public Retail() As RetailRpt <-- this one is nested
    Public NetSellAmt As Integer
    Public PayOut As Integer
    Public AgentDiscountAmt As Integer
    Public NetToPay As Integer
End Structure

我已经从 datagridview 的数据源中添加了 DSRPT 结构。但不幸的是,我无法在 datagridview 行中使用 [+] 显示嵌套结构数据。 请帮助我,我在 Window 窗体应用程序上使用 VB.NET。
提前致谢。

【问题讨论】:

  • 目前我正在使用此代码将主要结构添加到绑定源 -----> Dim GetDSRpt() As localhost.DSRpt Dim ret() As localhost.RetailRpt GetDSRpt = ws.CreateDSRpt (FromDate, ToDate, 1) ret = GetDSRpt(0).Retail DSRptBindingSource.Clear() DSRptBindingSource.Add(GetDSRpt(0))
  • 请使用formatting将其编辑到您的问题中。
  • 我试图找出一个类似的问题:显示嵌套的 DataGridViews。到目前为止,我正在处理 DataGridViewBindingComplete 事件以“手动”填充字段 stackoverflow.com/questions/683796/… 希望这会有所帮助。

标签: .net vb.net datagridview


【解决方案1】:

我认为使用传统的 GridView 确实很难完成,我建议您使用 MSFlexGrid,或者如果它对您来说太难看,请尝试使用第三方控件,这里有一个关于它的线程:Good Quality Free Gridview for .NET WinForms

【讨论】:

    猜你喜欢
    • 2017-08-30
    • 2019-09-11
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2016-07-01
    相关资源
    最近更新 更多