Hi,
could you please help me how would I be able to give select All option for checkbox column, In my grid I have
could you please help me how would I be able to give select All option for checkbox column, In my grid I have
GridViewCheckBoxColumn. Header for that column shoud have checkbox, If I select that header check box all the checkbox in that column should be checked.
Thank you in Advance.
Raghu
30 Answers, 1 is accepted
0
Hello Ragupathi,
Thank you for contacting us.
I suggest using a custom header cell element. You should inherit the GridHeaderCellElement and add a RadCheckBoxElement in its children collection. Consider the code snippet below:
I hope this helps. Should you have any other questions don't hesitate to contact us.
Greetings,
Jack
the Telerik team
Check out Telerik Trainer, the state of the art learning tool for Telerik products.
Thank you for contacting us.
I suggest using a custom header cell element. You should inherit the GridHeaderCellElement and add a RadCheckBoxElement in its children collection. Consider the code snippet below:
void radGridView1_CreateCell(object sender, GridViewCreateCellEventArgs e) |
{ |
if (e.Row is GridTableHeaderRowElement && |
e.Column.HeaderText == "Option1") |
{ |
e.CellElement = new CheckBoxHeaderCell(e.Column, e.Row); |
} |
} |
public class CheckBoxHeaderCell : GridHeaderCellElement |
{ |
RadCheckBoxElement checkbox; |
public CheckBoxHeaderCell(GridViewColumn column, GridRowElement row) |
: base(column, row) |
{ |
} |
protected override void Dispose(bool disposing) |
{ |
if (disposing) |
{ |
checkbox.ToggleStateChanged -= new StateChangedEventHandler(checkbox_ToggleStateChanged); |
} |
base.Dispose(disposing); |
} |
protected override void CreateChildElements() |
{ |
base.CreateChildElements(); |
checkbox = new RadCheckBoxElement(); |
checkbox.ToggleStateChanged += new StateChangedEventHandler(checkbox_ToggleStateChanged); |
this.Children.Add(checkbox); |
ApplyThemeToElement(checkbox, "ControlDefault"); |
} |
protected override SizeF ArrangeOverride(SizeF finalSize) |
{ |
base.ArrangeOverride(finalSize); |
if (checkbox != null) |
{ |
RectangleF rect = GetClientRectangle(finalSize); |
checkbox.Arrange(new RectangleF(rect.Right - 20, (rect.Height - 20) / 2, 20, 20)); |
} |
return finalSize; |
} |
private void checkbox_ToggleStateChanged(object sender, StateChangedEventArgs args) |
{ |
for (int i = 0; i < this.GridControl.Rows.Count; i++) |
{ |
this.GridControl.Rows[i].Cells["Option1"].Value = this.checkbox.IsChecked; |
} |
} |
private void ApplyThemeToElement(RadItem item, string themeName) |
{ |
DefaultStyleBuilder builder = ThemeResolutionService.GetStyleSheetBuilder((RadControl)item.ElementTree.Control, |
item.GetThemeEffectiveType().FullName, string.Empty, themeName) as DefaultStyleBuilder; |
if (builder != null) |
{ |
item.Style = new XmlStyleSheet(builder.Style).GetStyleSheet(); |
} |
} |
} |
I hope this helps. Should you have any other questions don't hesitate to contact us.
Greetings,
Jack
the Telerik team
Check out Telerik Trainer, the state of the art learning tool for Telerik products.
0

pratt
Top achievements
Rank 1
answered on 04 Feb 2009, 04:13 AM
How can I align header checkbox with all checkboxes in checkbox column?Thanks
0
Hello pratt,
Thank you for writing us back.
The ArrangeOverride method of CheckBoxHeaderCell sets the position for all child elements including the position of the check box. The DesiredSize property of the checkbox contains the desired size for the element. So, the following expression can be used to calculate the correct position:
Here is the modified version of the ArrangeOverride method:
If you have any other questions, do not hesitate to ask.
Kind regards,
Jack
the Telerik team
Check out Telerik Trainer, the state of the art learning tool for Telerik products.
Thank you for writing us back.
The ArrangeOverride method of CheckBoxHeaderCell sets the position for all child elements including the position of the check box. The DesiredSize property of the checkbox contains the desired size for the element. So, the following expression can be used to calculate the correct position:
x = (finalSize.Width - checkbox.DesiredSize.Width) / 2 |
Here is the modified version of the ArrangeOverride method:
protected override SizeF ArrangeOverride(SizeF finalSize) |
{ |
base.ArrangeOverride(finalSize); |
if (checkbox != null) |
{ |
RectangleF rect = GetClientRectangle(finalSize); |
checkbox.Arrange(new RectangleF((finalSize.Width - checkbox.DesiredSize.Width) / 2, (rect.Height - 20) / 2, 20, 20)); |
} |
return finalSize; |
} |
If you have any other questions, do not hesitate to ask.
Kind regards,
Jack
the Telerik team
Check out Telerik Trainer, the state of the art learning tool for Telerik products.
0

Ragupathi
Top achievements
Rank 1
answered on 24 Feb 2009, 06:44 AM
Hi ,
thanks for your answers.
How do you unselect the header check box when unselect any of the checkbox in the grid row.
Thanks in advance,.
Ragupathi
thanks for your answers.
How do you unselect the header check box when unselect any of the checkbox in the grid row.
Thanks in advance,.
Ragupathi
0
Hi Ragupathi,
You can do this by handling he ValueChanged event. Take a look at the code below:
I prepared a method named SetCheckBoxState. Here is the modified CheckBoxHeaderCell class:
Please do not hesitate to write me if you need further assistance.
Regards,
Jack
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.
You can do this by handling he ValueChanged event. Take a look at the code below:
void radGridView1_ValueChanged(object sender, EventArgs e) |
{ |
GridCheckBoxCellElement checkBoxCell = sender as GridCheckBoxCellElement; |
if (checkBoxCell != null && !(bool)this.radGridView1.ActiveEditor.Value) |
{ |
CheckBoxHeaderCell cell = (CheckBoxHeaderCell)this.radGridView1.MasterGridViewInfo.TableHeaderRow.Cells["Option1"].CellElement; |
cell.SetCheckBoxState(Telerik.WinControls.Enumerations.ToggleState.Off); |
} |
} |
I prepared a method named SetCheckBoxState. Here is the modified CheckBoxHeaderCell class:
public class CheckBoxHeaderCell : GridHeaderCellElement |
{ |
RadCheckBoxElement checkbox; |
private bool suspendProcessingToggleStateChanged; |
public CheckBoxHeaderCell(GridViewColumn column, GridRowElement row) |
: base(column, row) |
{ |
} |
public RadCheckBoxElement CheckBox |
{ |
get |
{ |
EnsureChildElements(); |
return checkbox; |
} |
} |
public void SetCheckBoxState(Telerik.WinControls.Enumerations.ToggleState state) |
{ |
suspendProcessingToggleStateChanged = true; |
this.CheckBox.ToggleState = state; |
suspendProcessingToggleStateChanged = false; |
} |
protected override void Dispose(bool disposing) |
{ |
if (disposing) |
{ |
checkbox.ToggleStateChanged -= new StateChangedEventHandler(checkbox_ToggleStateChanged); |
} |
base.Dispose(disposing); |
} |
protected override void CreateChildElements() |
{ |
base.CreateChildElements(); |
checkbox = new RadCheckBoxElement(); |
checkbox.ToggleStateChanged += new StateChangedEventHandler(checkbox_ToggleStateChanged); |
this.Children.Add(checkbox); |
ApplyThemeToElement(checkbox, "ControlDefault"); |
} |
protected override SizeF ArrangeOverride(SizeF finalSize) |
{ |
base.ArrangeOverride(finalSize); |
if (checkbox != null) |
{ |
RectangleF rect = GetClientRectangle(finalSize); |
checkbox.Arrange(new RectangleF(rect.Right - 20, (rect.Height - 20) / 2, 20, 20)); |
} |
return finalSize; |
} |
private void checkbox_ToggleStateChanged(object sender, StateChangedEventArgs args) |
{ |
if (!suspendProcessingToggleStateChanged) |
{ |
for (int i = 0; i < this.GridControl.Rows.Count; i++) |
{ |
this.GridControl.Rows[i].Cells["Option1"].Value = this.checkbox.IsChecked; |
} |
} |
} |
private void ApplyThemeToElement(RadItem item, string themeName) |
{ |
DefaultStyleBuilder builder = ThemeResolutionService.GetStyleSheetBuilder((RadControl)item.ElementTree.Control, |
item.GetThemeEffectiveType().FullName, string.Empty, themeName) as DefaultStyleBuilder; |
if (builder != null) |
{ |
item.Style = new XmlStyleSheet(builder.Style).GetStyleSheet(); |
} |
} |
} |
Please do not hesitate to write me if you need further assistance.
Regards,
Jack
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.
0

jerry
Top achievements
Rank 1
answered on 01 May 2009, 02:25 PM
Jack,
Using your above code when I have everything checked and remove a check from just 1 row all the checks are removed. Is this how the code should work? I wanted it to just remove the checkbox in the header and the one that I checked off. The ToggleStateChanged event is firing and removing them all how can I have it just remove the header checkbox and the one I checked off?
Thank you
Jerry
Using your above code when I have everything checked and remove a check from just 1 row all the checks are removed. Is this how the code should work? I wanted it to just remove the checkbox in the header and the one that I checked off. The ToggleStateChanged event is firing and removing them all how can I have it just remove the header checkbox and the one I checked off?
Thank you
Jerry
0
Hi jerry,
The suspendProcessingToggleStateChanged property prevents unchecking all of the check boxes. You have to include it as a condition in the ToggleStateChanged event in your custom CheckBoxHeaderCell class as in Jack's last example code.
Do not hesitate to write us back if you have other questions.
Best wishes,
Martin Vasilev
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.
The suspendProcessingToggleStateChanged property prevents unchecking all of the check boxes. You have to include it as a condition in the ToggleStateChanged event in your custom CheckBoxHeaderCell class as in Jack's last example code.
Do not hesitate to write us back if you have other questions.
Best wishes,
Martin Vasilev
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.
0

Ajay
Top achievements
Rank 1
answered on 08 Dec 2009, 06:18 AM
Hi
Thanks for the usefull post . I need to know that how can i set focus the select all
check box in header coloum while traversing the grid through keyboard.
Thanks
Ajay Yadav
Thanks for the usefull post . I need to know that how can i set focus the select all
check box in header coloum while traversing the grid through keyboard.
Thanks
Ajay Yadav
0
Hello Ajay,
You cannot set the focus on a HeaderCellElement. However, you can access the check box element in the customized header cell using the following code:
Kind regards,
Martin Vasilev
the Telerik team
Instantly find answers to your questions on the new Telerik Support Portal.
Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
You cannot set the focus on a HeaderCellElement. However, you can access the check box element in the customized header cell using the following code:
((RadCheckBoxElement)
this
.radGridView1.MasterGridViewInfo.TableHeaderRow.Cells[0].CellElement.Children[1]).IsChecked =
false
;
Kind regards,
Martin Vasilev
the Telerik team
Instantly find answers to your questions on the new Telerik Support Portal.
Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
0

Sean
Top achievements
Rank 1
answered on 04 Jan 2010, 06:06 PM
Hello,
I had implemented this code in my project and everything was working fine. I am now trying to upgrade to the Q3 2009 SP1 release of the WinForms controls and I get an error in the following method:
It appears that the item.ElementTree property is nothing, which causes the first line of code to fail. Is there a way to make this work with the latest version of the Telerik controls?
Thanks,
Sean
I had implemented this code in my project and everything was working fine. I am now trying to upgrade to the Q3 2009 SP1 release of the WinForms controls and I get an error in the following method:
private void ApplyThemeToElement(RadItem item, string themeName) |
{ |
DefaultStyleBuilder builder = ThemeResolutionService.GetStyleSheetBuilder((RadControl)item.ElementTree.Control, |
item.GetThemeEffectiveType().FullName, string.Empty, themeName) as DefaultStyleBuilder; |
if (builder != null) |
{ |
item.Style = new XmlStyleSheet(builder.Style).GetStyleSheet(); |
} |
} |
It appears that the item.ElementTree property is nothing, which causes the first line of code to fail. Is there a way to make this work with the latest version of the Telerik controls?
Thanks,
Sean
0

Sean
Top achievements
Rank 1
answered on 04 Jan 2010, 08:30 PM
Okay, I think I found the problem. I changed the code to this, and everything appears to work now (I only changed the first line of the function).
private void ApplyThemeToElement(RadItem item, string themeName) |
{ |
DefaultStyleBuilder builder = ThemeResolutionService.GetStyleSheetBuilder(item); |
if (builder != null) { |
item.Style = new XmlStyleSheet(builder.Style).GetStyleSheet(); |
} |
} |
0
Hello Sean,
In the latest version Q3 2009 SP1 we changed life cycle of the RadElements and that is why ElementTree still is not initialized when the ApplyThemeToElement has been called. To resolve this, you have to override Initialize method and call ApplyThemeToElement there, but not in CreateChildElements method:
Having the above code applied, you do not need to modify the ApplyThemeToElement method.
Kind regards,
Martin Vasilev
the Telerik team
Instantly find answers to your questions on the new Telerik Support Portal.
Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
In the latest version Q3 2009 SP1 we changed life cycle of the RadElements and that is why ElementTree still is not initialized when the ApplyThemeToElement has been called. To resolve this, you have to override Initialize method and call ApplyThemeToElement there, but not in CreateChildElements method:
public
override
void
Initialize()
{
base
.Initialize();
ApplyThemeToElement(_checkbox,
"ControlDefault"
);
}
Having the above code applied, you do not need to modify the ApplyThemeToElement method.
Kind regards,
Martin Vasilev
the Telerik team
Instantly find answers to your questions on the new Telerik Support Portal.
Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
0

Damien
Top achievements
Rank 1
answered on 27 Jan 2010, 12:03 PM
Hi Martin,
Like Sean, I have upgraded a project that uses the CheckBoxHeaderCell class to Q3 2009 SP1. Using your changes in the last post, I have been able to run the project again, however... there is now a very long delay in the time it takes to apply the checkbox to each row. The delay is in the order of 2 seconds per row, where previously it was almost instantaneuos for 1000 rows.
Any ideas why this would be the case with the new version?
Cheers,
Damien
Like Sean, I have upgraded a project that uses the CheckBoxHeaderCell class to Q3 2009 SP1. Using your changes in the last post, I have been able to run the project again, however... there is now a very long delay in the time it takes to apply the checkbox to each row. The delay is in the order of 2 seconds per row, where previously it was almost instantaneuos for 1000 rows.
Any ideas why this would be the case with the new version?
Cheers,
Damien
0
Hi Damien,
I am unable to reproduce the described performance delay. However, there could be something specific to your scenario that causes it. Please, open a new support ticket and send me a small sample project that demonstrates it. This will help me to investigate the case in detail and provide further assistance.
Greetings,
Martin Vasilev
the Telerik team
Instantly find answers to your questions on the new Telerik Support Portal.
Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
I am unable to reproduce the described performance delay. However, there could be something specific to your scenario that causes it. Please, open a new support ticket and send me a small sample project that demonstrates it. This will help me to investigate the case in detail and provide further assistance.
Greetings,
Martin Vasilev
the Telerik team
Instantly find answers to your questions on the new Telerik Support Portal.
Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
0

Eric
Top achievements
Rank 1
answered on 26 Apr 2010, 03:58 PM
Hi,
I am using RadControls WinForms 2009 3 1203 and I have a compile error if I include the Dispose method as proposed in this thread. Is there an other way to achieve this or simply remove it?
Method:
protected override void Dispose(bool disposing)
{
if (disposing)
{
checkbox.ToggleStateChanged -= new StateChangedEventHandler(checkbox_ToggleStateChanged);
}
base.Dispose(disposing);
}
Compile error:
CheckBoxHeaderCell.Dispose(bool)': cannot override inherited member 'Telerik.WinControls.DisposableObject.Dispose(bool)' because it is not marked virtual, abstract, or override
Regards,
Eric
0
Hello Eric,
Thank you for contacting us.
Yes, we have changed the Dispose method and now it is not marked as Virtual and cannot be overriden. You should use DisposeManagedResources instead:
A bit off topic, please ask the person who has purchased our controls in your company to add you as a License Developer to the purchase. This will give you full access to the products your company has purchased, to our downloads section, and to our support ticketing system. Additionally, all your questions will be reviewed according to the license you have. More information on License Developers you can find here: www.telerik.com/account/faqs.aspx.
Greetings,
Martin Vasilev
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items.
Thank you for contacting us.
Yes, we have changed the Dispose method and now it is not marked as Virtual and cannot be overriden. You should use DisposeManagedResources instead:
protected
override
void
DisposeManagedResources()
{
checkbox.ToggleStateChanged -=
new
StateChangedEventHandler(checkbox_ToggleStateChanged);
base
.DisposeManagedResources();
}
A bit off topic, please ask the person who has purchased our controls in your company to add you as a License Developer to the purchase. This will give you full access to the products your company has purchased, to our downloads section, and to our support ticketing system. Additionally, all your questions will be reviewed according to the license you have. More information on License Developers you can find here: www.telerik.com/account/faqs.aspx.
Greetings,
Martin Vasilev
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items.
0

Armen
Top achievements
Rank 1
answered on 05 Aug 2010, 03:42 PM
Hi All! radGridView1_ValueChanged event handler code is not working with Q2 2010 Winform. There is no 'CellElement' property for Cells["Option1"] cell. How to call SetCheckBoxState method in this case?
0

Armen
Top achievements
Rank 1
answered on 06 Aug 2010, 09:31 AM
Also there is no Initialize method with zero arguments to override in Q2 2010. I can override Initialize method with two arguments. Even in this case item.ElementTree is null in ApplyThemeToElement method.
public
override
void
Initialize(GridViewColumn column, GridRowElement row)
{
base
.Initialize(column, row);
ApplyThemeToElement(checkbox,
"ControlDefault"
);
}
0
Hello Armen,
Actually, there are a couple of changes in the Q2 2010 RadGridView which do not allow the old code of adding check box in header to work as expected. I can suggest a slightly different approach to implement the same functionality in the new grid.
First, create a custom cell class with an added check box element. It should override the ThemeEffectiveType property to apply grid's theme and also should override IsCompatible to prevent check-box from "jumping" between columns because of the grid columns virtualization:
Further, create a custom column class which inherits GridViewCheckBoxColumn. It should use the custom header cell element and also disable sorting and hard-coded the name:
Finally, add the custom column to your RadGridView and everything should work as expected:
Sincerely yours,
Martin Vasilev
the Telerik team
Actually, there are a couple of changes in the Q2 2010 RadGridView which do not allow the old code of adding check box in header to work as expected. I can suggest a slightly different approach to implement the same functionality in the new grid.
First, create a custom cell class with an added check box element. It should override the ThemeEffectiveType property to apply grid's theme and also should override IsCompatible to prevent check-box from "jumping" between columns because of the grid columns virtualization:
public
class
CheckBoxHeaderCell : GridHeaderCellElement
{
private
ToggleState _state;
RadCheckBoxElement _checkbox;
private
bool
_suspendProcessingToggleStateChanged;
public
CheckBoxHeaderCell(GridViewColumn column, GridRowElement row)
:
base
(column, row)
{
_state = ToggleState.Off;
}
public
ToggleState State
{
get
{
return
_state; }
set
{
this
.SetCheckBoxState(value);
}
}
//Use this header cell only for column with "SelectColumn" name.
//This prevents check-box "jumping" between columns because of column virtualization
public
override
bool
IsCompatible(GridViewColumn data,
object
context)
{
return
base
.IsCompatible(data, context) && data.Name ==
"SelectColumn"
;
}
private
void
SetCheckBoxState(ToggleState state)
{
_suspendProcessingToggleStateChanged =
true
;
this
._checkbox.ToggleState = state;
_state = state;
_suspendProcessingToggleStateChanged =
false
;
}
protected
override
void
CreateChildElements()
{
base
.CreateChildElements();
_checkbox =
new
RadCheckBoxElement();
_checkbox.ToggleStateChanged +=
new
StateChangedEventHandler(checkbox_ToggleStateChanged);
this
.Children.Add(_checkbox);
}
protected
override
SizeF ArrangeOverride(SizeF finalSize)
{
SizeF size =
base
.ArrangeOverride(finalSize);
RectangleF rect = GetClientRectangle(finalSize);
this
._checkbox.Arrange(
new
RectangleF((finalSize.Width -
this
._checkbox.DesiredSize.Width) / 2, (rect.Height - 20) / 2, 20, 20));
return
size;
}
private
void
checkbox_ToggleStateChanged(
object
sender, StateChangedEventArgs args)
{
if
(!_suspendProcessingToggleStateChanged &&
this
.ColumnInfo
is
GridViewCheckBoxColumn)
{
bool
valueState =
false
;
valueState = args.ToggleState == ToggleState.On ?
true
:
false
;
for
(
int
i = 0; i <
this
.ViewTemplate.RowCount; i++)
{
this
.ViewTemplate.Rows[i].Cells[
this
.ColumnIndex].Value = valueState;
}
}
}
//Use appropriate theme for the custom cell
protected
override
Type ThemeEffectiveType
{
get
{
return
typeof
(GridHeaderCellElement);
}
}
}
Further, create a custom column class which inherits GridViewCheckBoxColumn. It should use the custom header cell element and also disable sorting and hard-coded the name:
class
SelectCheckBoxColumn : GridViewCheckBoxColumn
{
protected
override
void
Initialize()
{
//set AllowSort and Name in column initialization. These properties must remains the same.
this
.AllowSort =
false
;
this
.Name =
"SelectColumn"
;
base
.Initialize();
}
/// <summary>
/// Hard code the column name to SelectColumn
/// </summary>
public
override
string
Name
{
get
{
return
base
.Name;
}
set
{
base
.Name =
"SelectColumn"
;
}
}
/// <summary>
/// Allow sort should be always false
/// </summary>
public
override
bool
AllowSort
{
get
{
return
base
.AllowSort;
}
set
{
base
.AllowSort =
false
;
}
}
//Use custom check box cell for header
public
override
Type GetCellType(GridViewRowInfo row)
{
if
(row
is
GridViewTableHeaderRowInfo)
{
return
typeof
(CheckBoxHeaderCell);
}
return
base
.GetCellType(row);
}
}
Finally, add the custom column to your RadGridView and everything should work as expected:
SelectCheckBoxColumn checkColumn =
new
SelectCheckBoxColumn();
this
.radGridView1.Columns.Insert(0, checkColumn);
Sincerely yours,
Martin Vasilev
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
0

Armen
Top achievements
Rank 1
answered on 12 Aug 2010, 11:52 AM
Hi, Martin Vasilev. Thank you for reply. It working but still issue with SetCheckBoxState method calling is not solved. After all checkbox selecting when I unselect one checkbox, top checkbox must be unselected. How to call SetCheckBoxState method?
0

kapil
Top achievements
Rank 1
answered on 13 Aug 2010, 09:09 AM
Why you guys don't have backward compatibility support. Everytime there is new version release, it breaks the old things. Can you pls. tell me how to get header row CellElement with new version.
0
Hi there,
To uncheck the header cell element when one of the column's cell has been unchecked, you can use the CallValueChanged event:
Kapil, in the new version of RadGridView there is not a direct reference to the CellElement in HeaderRow because it uses column virtualization and CellElement could not be created when you are trying to access it. The right way to get it is through handling the ViewCellFormatting event.
Sincerely yours,
Martin Vasilev
the Telerik team
To uncheck the header cell element when one of the column's cell has been unchecked, you can use the CallValueChanged event:
public
class
CheckBoxHeaderCell : GridHeaderCellElement
{
private
ToggleState _state;
RadCheckBoxElement _checkbox;
private
bool
_suspendProcessingToggleStateChanged;
public
CheckBoxHeaderCell(GridViewColumn column, GridRowElement row)
:
base
(column, row)
{
_state = ToggleState.Off;
}
protected
override
void
OnLoaded()
{
this
.GridControl.CellValueChanged +=
new
GridViewCellEventHandler(GridControl_CellValueChanged);
base
.OnLoaded();
}
void
GridControl_CellValueChanged(
object
sender, GridViewCellEventArgs e)
{
if
(e.Column ==
this
.ColumnInfo && (
bool
)e.Value ==
false
)
{
SetCheckBoxState(ToggleState.Off);
}
}
//....
}
Kapil, in the new version of RadGridView there is not a direct reference to the CellElement in HeaderRow because it uses column virtualization and CellElement could not be created when you are trying to access it. The right way to get it is through handling the ViewCellFormatting event.
Sincerely yours,
Martin Vasilev
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
0

Igor Korolenko
Top achievements
Rank 1
answered on 10 Sep 2010, 04:58 PM
Hi Martin,
in your sample code
Thanks
in your sample code
this
.GridControl.CellValueChanged
gets fired up only when user moves out of a cell. Which event should be used to uncheck header checkbox when one of the cell checkboxes gets unchecked?Thanks
0
Hello Igor Korolenko,
It is possible to uncheck the header cell when one of the data cells is unchecked on the MouseDown event. However, this could cause some inconsistency, because the cell value is committed when you move out of that cell, but not when you check/uncheck the check-mark element. If you still want to implement this, you can use the following sample code:
I hope this helps.
All the best,
Martin Vasilev
the Telerik team
It is possible to uncheck the header cell when one of the data cells is unchecked on the MouseDown event. However, this could cause some inconsistency, because the cell value is committed when you move out of that cell, but not when you check/uncheck the check-mark element. If you still want to implement this, you can use the following sample code:
protected
override
void
OnLoaded()
{
//this.GridControl.CellValueChanged += new GridViewCellEventHandler(GridControl_CellValueChanged);
this
.GridControl.MouseDown +=
new
System.Windows.Forms.MouseEventHandler(GridControl_MouseDown);
base
.OnLoaded();
}
void
GridControl_MouseDown(
object
sender, System.Windows.Forms.MouseEventArgs e)
{
RadCheckmark check =
this
.GridControl.ElementTree.GetElementAtPoint(e.Location)
as
RadCheckmark;
if
(check !=
null
)
{
if
(check.CheckState == ToggleState.On)
{
SetCheckBoxState(ToggleState.Off);
}
}
}
I hope this helps.
All the best,
Martin Vasilev
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
0

Carisch
Top achievements
Rank 1
answered on 01 Nov 2010, 11:38 PM
This is a fine solution if you only want a single column that is unbound, but that is not my requirement.
Can you provide an example where you have at least two bound columns that have data within them, with no hardcoded column name.
Can you provide an example where you have at least two bound columns that have data within them, with no hardcoded column name.
0
Hello Brian,
Thank you for contacting us.
I am attaching a modified sample project to this message. It demonstrates a slightly different approach, which allows for adding more than one bound columns with check-box element in the header. Please take a look at it and let me know if you have any additional questions.
Regards,
Martin Vasilev
the Telerik team
Thank you for contacting us.
I am attaching a modified sample project to this message. It demonstrates a slightly different approach, which allows for adding more than one bound columns with check-box element in the header. Please take a look at it and let me know if you have any additional questions.
Regards,
Martin Vasilev
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
0

pratt
Top achievements
Rank 1
answered on 20 Apr 2011, 05:09 AM
This has unpredictable behaviour. In one case even though data source is properly assigned and it is showing the value of checkboxelement as true, it does not draw checkbox as ticked. They are actully ticked but just does not show it. weird!!
How to do force redraw of checkbox in checkboxcolumn.
How to do force redraw of checkbox in checkboxcolumn.
0
Hello pratt,
Thank you for writing.
I am afraid I am not sure what exactly is the issue in your scenario. From your description it seems like an issue, which is not related to the header cell check box. Could you please open a new support ticket and send me a small sample? This will allow me to investigate your case further and provide you with accurate assistance.
Kind regards,
Martin Vasilev
the Telerik team
Thank you for writing.
I am afraid I am not sure what exactly is the issue in your scenario. From your description it seems like an issue, which is not related to the header cell check box. Could you please open a new support ticket and send me a small sample? This will allow me to investigate your case further and provide you with accurate assistance.
Kind regards,
Martin Vasilev
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
0

pratt
Top achievements
Rank 1
answered on 28 Apr 2011, 12:49 AM
yes it is not related with header cell chek box but it is happening by using checkboxcolumn in the grid with the checkboxheadercell.
steps are as follows
1) CustomRadGridview with checkboxcolumn added at design time
2) declare bindingsource inside the form
3) Create BindingSource object with new operator in constructor
4) add two columns at runtime and assign bindingsource object as datasource for customradgridview so it has three columns now
5) Source List of objects added to datasource of Bindingsource object
6) form loads and displays CustomradGrid with all objects
7)select two checkbox and perform data operations
8) reassign source list to bindingsource object
9) It will not retain checks(I also tried with boolean data bound checkbox column, it shows that check property is true or even checbox checked for unbound columnm but it does not display it)
10) if I select another checkbox then previous two and perform data operations , it actully applies tocurrent ticked check box and previous two checkboxes as well. so what it means is they are actully ticked but just not displaying it.
Basicaly you can try refreshing datasource of bindingsource object then it does not realod the grid with checkbox column properly.
My exapme will be complex.Please follow above steps for simple test project and you can see that behaviour which seems like Radgrid issue.
steps are as follows
1) CustomRadGridview with checkboxcolumn added at design time
2) declare bindingsource inside the form
3) Create BindingSource object with new operator in constructor
4) add two columns at runtime and assign bindingsource object as datasource for customradgridview so it has three columns now
5) Source List of objects added to datasource of Bindingsource object
6) form loads and displays CustomradGrid with all objects
7)select two checkbox and perform data operations
8) reassign source list to bindingsource object
9) It will not retain checks(I also tried with boolean data bound checkbox column, it shows that check property is true or even checbox checked for unbound columnm but it does not display it)
10) if I select another checkbox then previous two and perform data operations , it actully applies tocurrent ticked check box and previous two checkboxes as well. so what it means is they are actully ticked but just not displaying it.
Basicaly you can try refreshing datasource of bindingsource object then it does not realod the grid with checkbox column properly.
My exapme will be complex.Please follow above steps for simple test project and you can see that behaviour which seems like Radgrid issue.
0
Hello pratt,
Thank you for getting back to me.
I have tried the re-binding scenario following your description. However, everything with checkbox columns work as expected on my side. Do you use the latest version of RadControls Q1 2011 SP1 (2011.1.11.426)? If not, please download and give it a try. If you still experience any issues, I would need a small sample project, which demonstrates your exact approach.
Please note that you have to open a new support ticket to send me your files.
Regards,
Martin Vasilev
the Telerik team
Thank you for getting back to me.
I have tried the re-binding scenario following your description. However, everything with checkbox columns work as expected on my side. Do you use the latest version of RadControls Q1 2011 SP1 (2011.1.11.426)? If not, please download and give it a try. If you still experience any issues, I would need a small sample project, which demonstrates your exact approach.
Please note that you have to open a new support ticket to send me your files.
Regards,
Martin Vasilev
the Telerik team