本文介绍了如何在DevExpress GridView中查找展开/折叠的主行和分组行的数量?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我目前在Visual Studio 2010中使用DevExpress 10.2。在我试图打印DevExpress GridControl的当前用户视图,用户可以选择展开或折叠的主行和/或组部分。我被告知这是不可能的。我现在决定使用以下代码:

I am currently using DevExpress 10.2 within Visual Studio 2010. In a previous question I was trying to print the current user view of a DevExpress GridControl with the user's choice of expanded or collapsed master rows and/or group sections. I was told this was not possible at this time. I have now decided to use the following code:

gvPOinvoiceBanded.OptionsPrint.ExpandAllGroups = False
gvPOinvoiceBanded.OptionsPrint.ExpandAllDetails = False

当我希望它在打印时完全折叠,默认情况下设置为

when I want it to be completely collapsed while printing as by default these are set to true.

我只是想知道有没有办法检查扩展主列的总数或合拢的主行总数。我也想为群组做同样的事情,因为你们可以让主体行不会扩展组。

I was just wondering if there is someway to check either the total number of expanded master rows or the total number of collapsed master rows. I would also like to do the same thing for the groups as you can have the groups expanded while the master rows are not.

推荐答案

您可以使用这样的循环来获取展开的组行数:

You can get the number of expanded group rows using a loop like this:

    Dim ExpandedGroupCount As Integer = 0
    Dim Handle As Integer = -1  'group rows have negative row handles
    Do Until GridView1.GetRow(Handle) Is Nothing
        If GridView1.GetRowExpanded(Handle) Then
            ExpandedGroupCount += 1
        End If
        Handle -= 1
    Loop
    'Do whatever with expanded group count
    MsgBox(String.Format("Number of Expanded Group Rows: {0}{2}Number of Group Rows: {1}",
          ExpandedGroupCount, Math.Abs(Handle + 1), Environment.NewLine))

同样,您可以这样做来获得扩展主列的计数:

Similarly, you can do this to get the count of expanded master rows:

    Handle = 0
    Dim ExpandedMasterRowCount As Integer = 0
    Do Until GridView1.GetRow(Handle) Is Nothing
        If GridView1.IsMasterRow(Handle) Then
            If GridView1.GetMasterRowExpanded(Handle) Then
                ExpandedMasterRowCount += 1
            End If
        End If
        Handle += 1
    Loop
    MsgBox(String.Format("Number of Expanded Master Rows: {0}", ExpandedMasterRowCount))

当然,如果您只是检查,以便您可以看到是否需要设置崩溃这可能是不值得的努力。没有直接的属性可以提供您要查找的数据。

Of course, if you are only checking so that you can see if you need to set the collapse this probably isn't worth the effort. There is no direct property that provides the counts you are looking for.

您还可能使用行被折叠并展开以跟踪计数的事件变化。你必须小心,因为事件只有在扩大或崩溃时才会发生一切。所以如果你去那个方法,一定要检查 GridControl.InvalidRowHandle 的事件参数参数中的rowHandle。这是在崩溃或全部展开的情况下使用的值。

You could also probably use the events that fire when rows are collapsed and expanded to track the count as it changes. You have to be careful with that though because the event only fires once when expand or collapse all happens. So if you go with that method be sure to check the rowHandle in the event arguments parameter for GridControl.InvalidRowHandle. That is the value used in the case of collapse or expand all.

这篇关于如何在DevExpress GridView中查找展开/折叠的主行和分组行的数量?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-24 07:15