This is a migrated thread and some comments may be shown as answers.

Unbound RadGridView CheckboxColumn Behavior

1 Answer 133 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Bob
Top achievements
Rank 1
Bob asked on 08 Jun 2009, 09:05 PM
I have an unbound radgridview that I populate from a .CSV file.

I used AddCheckboxColumn() code I found in this forum to add a 'Select All' header checkbox.

I have two issues.

I want to enable and disable a button on the form based on 'all checkboxes cleared' = disabled and 'all checkboxes selected' = enabled

I can do this by adding ...

            If valueState = False And frmClientsImport.btnAddToDB.Enabled = True Then
                frmClientsImport.btnAddToDB.Enabled = False
            ElseIf valueState = True And frmClientsImport.btnAddToDB.Enabled = False And Not frmClientsImport.cboCustomers Is Nothing Then
                frmClientsImport.btnAddToDB.Enabled = True
            End If

...to Private Sub checkbox_ToggleStateChanged(ByVal sender As Object, ByVal args As StateChangedEventArgs)

but this is obviously not the way to do it because then I've kind of locked the subroutine to the specific radgridview.

Second, if an individual checkbox is selected/deselected I want to enable the same button as long as at least one row has a checkbox checked and disable the button if no rows have the checkbox checked. I tried the .ValueChanged event but it doesn't seem to report the state correctly.

1 Answer, 1 is accepted

Sort by
0
Nikolay
Telerik team
answered on 15 Jun 2009, 05:31 PM
Hello Bob,

Thank you for the questions.

Please find their answer below:

  1. I am not quite sure that I fully understand the issue that you have in your scenario. Could you please be more specific about it?
  2. Currently, when ValueChanged is fired, you can get the new value from the RadCheckBoxEditor:
    void radGridView1_ValueChanged(object sender, EventArgs e)  
    {  
        if (this.radGridView1.ActiveEditor is RadCheckBoxEditor)  
        {  
            if ((bool)((RadCheckBoxEditor)this.radGridView1.ActiveEditor).Value == true)  
            {  
                Console.WriteLine("True");  
            }  
            else 
            {  
                Console.WriteLine("False");  
            }  
        }  

If you have additional questions, feel free to contact me.

Kind regards,
Nikolay
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Check out the tips for optimizing your support resource searches.
Tags
GridView
Asked by
Bob
Top achievements
Rank 1
Answers by
Nikolay
Telerik team
Share this question
or