8 Answers, 1 is accepted
0
Accepted

Richard Slade
Top achievements
Rank 2
answered on 17 Nov 2010, 09:48 PM
Hello Igor,
There is no event directly, but you can subscribe to the RadPropertyChanged event of each column and then inpect the property to see if IsVisible has changed.
Place this code after the columns have been created: (In databindingcomplete for example, or after adding columns manually)
then handle the event
Hope this helps, but let me know if you need more assistance.
Richard
EDIT: This will also work to show when the column has been dragged back in via the column chooser
There is no event directly, but you can subscribe to the RadPropertyChanged event of each column and then inpect the property to see if IsVisible has changed.
Place this code after the columns have been created: (In databindingcomplete for example, or after adding columns manually)
foreach
(GridViewColumn column
in
this
.radGridView1.Columns)
{
column.RadPropertyChanged +=
new
Telerik.WinControls.RadPropertyChangedEventHandler(
this
.ColumnRadPropertyChangedHandler);
}
then handle the event
private
void
ColumnRadPropertyChangedHandler(
object
sender, Telerik.WinControls.RadPropertyChangedEventArgs e)
{
if
(String.Equals(e.Property.Name,
"IsVisible"
))
{
if
(((GridViewColumn)sender).IsVisible)
{
MessageBox.Show(sender.ToString() +
" is now being made visible"
);
}
else
{
MessageBox.Show(sender.ToString() +
" is now being made not visible"
);
}
}
}
Hope this helps, but let me know if you need more assistance.
Richard
EDIT: This will also work to show when the column has been dragged back in via the column chooser
0

IGOR
Top achievements
Rank 1
answered on 18 Nov 2010, 02:45 PM
Thanks Richard.
Your help was great and this example is just perfect.
Thanks a lot again.
Igor
Your help was great and this example is just perfect.
Thanks a lot again.
Igor
0

Richard Slade
Top achievements
Rank 2
answered on 18 Nov 2010, 02:50 PM
Hi Igor,
I'm very glad that helped.
All the best
Richard
I'm very glad that helped.
All the best
Richard
0

scottw
Top achievements
Rank 1
answered on 25 Jan 2011, 09:16 PM
I am able to make an example grid work with the code you provide, but somehow something is different with the gridview in my app and the event handler only fires at the very beginning of the grid's life cycle when the property DataTypeHandler is being changed. When I hide or show columns or drag them from or to the column chooser, the event does not fire in my app, even though the codebase is the same.
I am hoping you have some thoughts as to why this might be?
I am hoping you have some thoughts as to why this might be?
0

Richard Slade
Top achievements
Rank 2
answered on 25 Jan 2011, 09:27 PM
Hi Scott,
If you#d like to post an example that replicates your issue, I'll be happy to take a look at it.
Regards,
Richard
If you#d like to post an example that replicates your issue, I'll be happy to take a look at it.
Regards,
Richard
0

scottw
Top achievements
Rank 1
answered on 26 Jan 2011, 09:18 PM
Richard,
I am having difficulty scaling the app down to something that can easily be posted. I can't reproduce the problem in a non-proprietary codebase or I would gladly post it for your perusal. In the app I created to try to reproduce it, the events fire and the MessageBox pops up fine. In my app, the outer if test is reached upon loading the grid in the first place, but the IsVisible test is never reached after the grid is populated with data.
If I can figure out how to show you the problem without having proprietary code, I will post it then.
Thanks anyway.
VSmirk (formerly "Scott")
I am having difficulty scaling the app down to something that can easily be posted. I can't reproduce the problem in a non-proprietary codebase or I would gladly post it for your perusal. In the app I created to try to reproduce it, the events fire and the MessageBox pops up fine. In my app, the outer if test is reached upon loading the grid in the first place, but the IsVisible test is never reached after the grid is populated with data.
If I can figure out how to show you the problem without having proprietary code, I will post it then.
Thanks anyway.
VSmirk (formerly "Scott")
0

scottw
Top achievements
Rank 1
answered on 27 Jan 2011, 06:10 PM
Figured it out. It seems that when you load a saved layout, any events that have been assigned are blown away.
0
Hi VSmirk,
Thank you for writing.
I think I was able to reproduce your scenario. You said that Richards code worked, but after saving and loading the layout, the event does not fire any more. This is an expected behavior, since when you load the layout all columns are being recreated and your subscription is to the "old" column instances and not to the recreated new column instances. The solution if you already did not get to it is to subscribe to the event in the LayoutLoaded event which is fired right after this operation.
I hope this information addresses your question. Let me know if you need anything else.
Richard, thank you for the community effort. Your Telerik points are updated for this.
Regards,
Stefan
the Telerik team
Thank you for writing.
I think I was able to reproduce your scenario. You said that Richards code worked, but after saving and loading the layout, the event does not fire any more. This is an expected behavior, since when you load the layout all columns are being recreated and your subscription is to the "old" column instances and not to the recreated new column instances. The solution if you already did not get to it is to subscribe to the event in the LayoutLoaded event which is fired right after this operation.
I hope this information addresses your question. Let me know if you need anything else.
Richard, thank you for the community effort. Your Telerik points are updated for this.
Regards,
Stefan
the Telerik team