I need some helps. I want make checkbox in main radgridview
when i checked it, all checkbox inside gridviewtemplate will checked too.
in radgridview i use group by, and how i can select checkbox based on group radgridview?
i attached my problem too
any suggestions?
thanks
16 Answers, 1 is accepted
A couple of questions,
Is that checkbox bound or not?
Is the hierarchy an object hierarchy or manually created hierarchy?
Best Regards,
Emanuel Varga
Telerik WinForms MVP
1. I use gridview checkbox column, is the right way or not?
2. Yes I use object hierarchy in radgrid
I want save them all in one table, so i have 2 field bit data type,
one for save chekbox in column "status" at my picture,
and other to save checkbox in column "statuswip"
Best Regards,
Walter
Could you please create a small sample app and post it here, it would be a lot faster and easier like that...
Hope this helps, if you have any other questions or comments, please let me know,
Best Regards,
Emanuel Varga
Telerik WinForms MVP
I can't attach my sample application because allowed extensions are : .gif, .jpg, .jpeg and .png..
My sample code is:
Imports Telerik.WinControls.UI
Imports Telerik.Data
Public Class Form1
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Dim xCity As DataTable
Dim xCountry As DataTable
Dim xConnection As New Koneksi
xCity = xConnection.ExecuteQuery("Select distinct Country.CountryID, CityID, statusCity from City,Country where Country.CountryID = City.CountryID")
xCountry = xConnection.ExecuteQuery("Select distinct Country.CountryID, statusCountry from Country, City where Country.CountryID = City.CountryID")
RadGridView1.DataSource = xCountry
Dim template As New GridViewTemplate()
template.DataSource = xCity
RadGridView1.MasterTemplate.Templates.Add(template)
Dim relation As New GridViewRelation(RadGridView1.MasterTemplate)
relation.ChildTemplate = template
relation.RelationName = "CountryCity"
relation.ParentColumnNames.Add("CountryID")
relation.ChildColumnNames.Add("CountryID")
RadGridView1.Relations.Add(relation)
End Sub
End Class
I want if i checked statusCountry, all of statusCity must be checked too..
I use SQL Server R2 for my connection. The authentication is Windows Authentication. File "connection.txt" is the server name of your computer.
Wish any good news from you..
Cheers..
My problem is how to checked all of "StatusCity" if I've already checked "StatusCountry"?
Wish any good news from you.. Cheers
You may consider using the ValueChanged event and ChildRows collection in order to implement the desired functionality:
Private
Sub
RadGridView1_CellValueChanged(
ByVal
sender
As
System.
Object
,
ByVal
e
As
Telerik.WinControls.UI.GridViewCellEventArgs)
Handles
RadGridView1.CellValueChanged
If
e.Column.Name =
"StatusCountry"
Then
For
Each
row
As
GridViewDataRowInfo
In
e.Row.ChildRows
row.Cells(
"StatusCity"
).Value = e.Value
Next
End
If
End
Sub
I hope this helps. Let me know if you have any additional questions.
Regards,
Martin Vasilev
the Telerik team
Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get it now >>
It's work..
Hmm.. But i still have a simple problem..
If i checked "StatusCountry" when my radgridview is expanded, i must scroll down or move to another row so "StatusCity" will checked all too.
Can you help me to find the solution about triggering childrows without scroll down or something like that??
Because i've already tried "radgridview1.refresh()" but it doesn't work.. Wish any good news from you.. Cheers..
Thank you for getting back to me.
If you want to change the check-state of the child rows immediately after checking/unchecking the parent row there is a slightly different approach which could match your requirement. Please consider the code bellow:
Private
currentCheckEditor
As
RadCheckBoxEditor
Private
Sub
radGridView1_CellBeginEdit(sender
As
Object
, e
As
GridViewCellCancelEventArgs)
Handles
radGridView1.CellBeginEdit
Me
.currentCheckEditor = TryCast(e.ActiveEditor, RadCheckBoxEditor)
If
e.Column.Name =
"StatusCountry"
AndAlso
Me
.currentCheckEditor IsNot
Nothing
Then
AddHandler
Me
.currentCheckEditor.ValueChanged,
AddressOf
editor_ValueChanged
End
If
End
Sub
Private
Sub
radGridView1_CellEndEdit(sender
As
Object
, e
As
GridViewCellEventArgs)
Handles
radGridView1.CellEndEdit
If
Me
.currentCheckEditor IsNot
Nothing
Then
RemoveHandler
Me
.currentCheckEditor.ValueChanged,
AddressOf
editor_ValueChanged
Me
.currentCheckEditor =
Nothing
End
If
End
Sub
Private
Sub
editor_ValueChanged(sender
As
Object
, e
As
EventArgs)
Dim
editor
As
RadCheckBoxEditor =
DirectCast
(sender, RadCheckBoxEditor)
Dim
value
As
ToggleState =
DirectCast
(editor.Value, ToggleState)
For
Each
row
As
var
In
Me
.radGridView1.CurrentRow.ChildRows
row.Cells(
"StatusCity"
).Value = value = ToggleState.[
On
]
Next
End
Sub
Write me back if you need any additional assistance.
Greetings,
Martin Vasilev
the Telerik team
Q2’11 SP1 of RadControls for WinForms is available for download (see what's new); also available is the Q3'11 Roadmap for Telerik Windows Forms controls.
Could by please tell me on how to get the event (checked / unchecked) of checkbox within the gridview?.
Thank you for writing.
You could use the ValueChanged event to track when some editor, including checkbox changes its value in RadGridView. Here is a sample code:
void
radGridView1_ValueChanged(
object
sender, EventArgs e)
{
RadCheckBoxEditor editor = sender as RadCheckBoxEditor;
if (editor != null)
{
//here the checkbox value is changed
}
}Off topic, please restrain from mixing different subjects in the same thread. Please refer to p.4 from our forum guidelines: http://www.telerik.com/community/forums/winforms/gridview/important-information-on-using-the-telerik-forums.aspx.
I hope this helps.
Kind regards,
Plamen
the Telerik team
I know this is a bit old, but I am having a problem with "ValueChanged" event to fire when using a Hierarchical Grid and the check box is in the 3rd level of the Hierarchy and I change the value. Is there a setting at the grid level that needs to be set? Our grid is a subclass of RadGridView with a much of settings set that we commonly set.
Thanks for the help
I know this is a bit old, but I am having a problem with "ValueChanged" event to fire when using a Hierarchical Grid and the check box is in the 3rd level of the Hierarchy and I change the value. Is there a setting at the grid level that needs to be set? Our grid is a subclass of RadGridView with a much of settings set that we commonly set.
Thanks for the help
[/quote]
The end result I am trying to do is change the text color if the check box in that row is checked, otherwise leave it the default color. The problem I am having, is that the RowFormatting is not firing every time I check or uncheck the checkbox. I had read somewhere in the past that I would have to validate the row, but if I can't capture when the check box is actually checked or unchecked, because value change event is not firing.
Hello, Mark,
Note that the GridViewCheckBoxColumn offers the EditMode property which controls when the value of the editor will be submitted to the cell. By default, the old behavior is kept (OnValidate) and the value will be submitted only when the current cell changes or the grid looses focus. The new value (OnValueChange) will submit the value immediately after the editor value changes. In this case, the grid wouldn't enter edit mode for the checkbox. Hence, the ValueChanged won't be fired.I would recommend you to set the GridViewCheckBoxColumn.EditMode property to OnValueChange. Thus, when you toggle the checkbox, the value will be immediately committed to the cell. Then, you can handle the CellValueChanged event and perform the desired action.
I hope this information helps. If you need any further assistance please don't hesitate to contact me.
Regards,
Dess | Tech Support Engineer, Sr.
Progress Telerik
Hello, guys,
When you populate the grid with, e.g. set the DataSource, it is expected that the columns are auto generated. Hence, after setting the DataSource, the RadGridView.Columns collection is expected to be filled with columns and you can access each column. It is necessary to cast the accessed column to GridViewCheckBoxColumn in order to have access to its EditMode property. private void RadForm1_Load(object sender, EventArgs e)
{
this.productsTableAdapter.Fill(this.nwindDataSet.Products);
this.radGridView1.DataSource = this.productsBindingSource;
GridViewCheckBoxColumn checkBoxColumn = this.radGridView1.Columns["Discontinued"] as GridViewCheckBoxColumn;
checkBoxColumn.EditMode = EditMode.OnValueChange;
this.radGridView1.CellEndEdit += RadGridView1_CellEndEdit;
}
private void RadGridView1_CellEndEdit(object sender, GridViewCellEventArgs e)
{
}
Regards,
Dess | Tech Support Engineer, Sr.
Progress Telerik