Anyone ever add a Check All button to check all checkboxes?

You rock! Happen to have the last one in VB?

Conceptual:


    Private Sub btnSelectAll_Click(ByVal sender As Object, ByVal args As System.EventArgs)
        ChangeAll(myGrid.Rows, True)
    End Sub

    Private Sub btnClearAll_Click(ByVal sender As Object, ByVal args As System.EventArgs)
        ChangeAll(myGrid.Rows, False)
    End Sub

    Public Sub ChangeAll(ByVal row As RowsCollection, ByVal val As Boolean)
        For Each r As UltraGridRow In row

            If r.[GetType]() = GetType(UltraGridGroupByRow) Then
                ChangeAll((CType(r, UltraGridGroupByRow)).Rows, val)
            Else
                r.Cells("Print").Value = val
            End If
        Next
    End Sub

    Private Sub btnHSelect_Click(ByVal sender As Object, ByVal args As System.EventArgs)
        If myGrid.Selected.Rows.Count > 0 Then

            For Each dr As UltraGridRow In myGrid.Selected.Rows
                dr.Cells("Print").Value = True
            Next
        Else
            MessageBox.Show("You must have rows selected in order to set for printing, please play again!")
        End If
    End Sub

Telerik code converter for the win!

1 Like

Stop giving away my secrets! I did it by hand for @SimpsonGranco since both him and I are from Michigan! Enduring this Cold Weather.

Also @rbucek notice how he only asked for

You rock! Happen to have the last one in VB? (The Last One!)

Didn’t want the first one.

1 Like

lol I liked how you added the option to unselect also in the last one because it would actually come in very handy. Michigan!

nice work @hkeric.wci

FWIW… if you notice performance issues because you’re selecting a huge number of rows, you can improve this by turning off row synchronization (infragistics mumbojumbo)

essentially you start with

// turn it off
myGrid.BeginUpdate();
myGrid.SuspendRowSynchronization();

// do stuff to your rows here


//turn it back on
myGrid.ResumeRowSynchronization();
myGrid.EndUpdate();	


4 Likes

I usually in E10 atleast use “Custom Actions” and then I trigger the Custom Action which triggers the BPM which does the work.

Sometimes I prompt the User with a BPM Form to ask for Criteria.

That’s a gem right there, I’d suggest a bookmark to anyone browsing this thread.

9 Likes

SuspendRowSynchronization and ResumeRowSynchronization methods can be used to temporarily suspend UltraGrid from responding to data source change notifications. When row syncrhonization is suspended, the UltraGrid will still mark the rows dirty so it will re-create the rows next time it gets painted.

EndUpdate Resets the Infragistics.Win.UltraControlBase.IsUpdating flag to false and optionally invalidates the control. You can pass a boolean to it.

Overall, it makes your updates faster, so the Grid doesnt repaint itself for every row, do the batch work, then repaint once.

So I was just about to begin toying with this when I noticed that your example selects rows and not checking the boxes on each row… Sorry, as you can tell, I’m not exactly a coder but can get by once started… lol

I got this to work for me, but I have multiple tabs. Is there any way to make 1 button work for whatever the currently active tab is it easier to just create separate buttons for each tab? If separate tabs, is there a way to make the buttons inactive if you are not on the respective tab?

I ended up making separate buttons for each tab and also added separate buttons for Checking All and Un-checking All per tab.

I am implementing a similar button and for some crazy reason, whatever row I’m selected on will not “check” unless I drag my mouse across the cell with the checkbox. Is there something special I need to do to get the selected row to update the UI? @Chris_Conn @hkeric.wci @rbucek

Just moving the mouse over the cells (without clicking) makes the checkbox appear? If that’s the case you are having a drawing issue. You need to let the grid know that something changed… (googling )

1 Like

FWIW, I was using the data grid method of setting all the checkboxes = true.

You didn’t forget this did you?

oTrans.NotifyAll();

ahh, I see, one sec

I added that and also set RowMod = “U” also to no avail.

Try this, courtesy of @josecgomez .

using System.Reflection;

MethodInfo mi = YourEpiDataView.GetType().GetMethod("InvokeExecute", BindingFlags.Instance | BindingFlags.NonPublic); 
mi.Invoke(YourEpiDataView, new object[]{ true });

I found another way to do it, but I forgot.

2 Likes

That didn’t work. This is happening in a button click event. I stuck that at the end of my button click code. Do I need to do anything within the EpiViewNotification?