Windows Vista Forums
Vista Forums Home Join Vista Forums Donate Vista Tutorials Tags

Welcome to Vista Forums we are your forum to discuss Windows Vista x64 and x86 systems. Whether you need help or just want to post an idea you have on Vista, this is the forum for you.
Register at Vista forums...the world biggest Windows Vista resource Join Vista Forums Now

Go Back   Vista Forums > Microsoft Technical Newsgroups > Avalon

How to specify an event handler for the GridViewColumnHeader control in C#?

Update your Vista Drivers Update Your Drivers Now!!
Closed Thread
 
Thread Tools Display Modes
Old 11-06-2006   #1 (permalink)
wackyphill@yahoo.com
Guest


 

How to specify an event handler for the GridViewColumnHeader control in C#?

I know its this for XAML:
<ListView GridViewColumnHeader.Click="MyHandlerFunc"/>

But how do you specify an event handler for the GridViewColumnHeader
control in C#?


My System SpecsSystem Spec
Old 11-06-2006   #2 (permalink)
Robin Davies
Guest


 

RE: How to specify an event handler for the GridViewColumnHeader contr

this.AddHandler(
GridViewColumnHeader.ClickEvent,
new RoutedEventHandler(MyHandlerFunc)
);


"wackyphill@yahoo.com" wrote:

> I know its this for XAML:
> <ListView GridViewColumnHeader.Click="MyHandlerFunc"/>
>
> But how do you specify an event handler for the GridViewColumnHeader
> control in C#?
>
>

My System SpecsSystem Spec
Old 11-06-2006   #3 (permalink)
Robin Davies
Guest


 

RE: How to specify an event handler for the GridViewColumnHeader contr

this.AddHandler(
GridViewColumnHeader.ClickEvent,
new RoutedEventHandler(MyHandlerFunc)
);


"wackyphill@yahoo.com" wrote:

> I know its this for XAML:
> <ListView GridViewColumnHeader.Click="MyHandlerFunc"/>
>
> But how do you specify an event handler for the GridViewColumnHeader
> control in C#?
>
>

My System SpecsSystem Spec
Old 11-07-2006   #4 (permalink)
Bob
Guest


 

RE: How to specify an event handler for the GridViewColumnHeader contr

In article <FF7A9030-14F8-49C5-BFC7-E16D34993EC9@microsoft.com>,
RobinDavies@discussions.microsoft.com says...
> this.AddHandler(
> GridViewColumnHeader.ClickEvent,
> new RoutedEventHandler(MyHandlerFunc)
> );
>
>
> "wackyphill@yahoo.com" wrote:
>
> > I know its this for XAML:
> > <ListView GridViewColumnHeader.Click="MyHandlerFunc"/>
> >
> > But how do you specify an event handler for the GridViewColumnHeader
> > control in C#?
> >
> >

>


I messed with this for a while and saw that it was already answered by
Robin. But, I don't see GridViewColumnHeader as a member of ListView or
GridView... I originally instantiated a new instance of
GridViewColumnHeader in my code (below) but noticed the code works
without that line. Where's GridViewColumnHeader from?

-- sorry for wordwrap---

using System;
using System.Windows;
using System.Windows.Controls;

namespace Test.GridViewColumnHeaderTest
{
class GridViewColumnHeaderTest : Window
{
[STAThread]
public static void Main()
{
Application app = new Application();
app.Run(new GridViewColumnHeaderTest());
}
public GridViewColumnHeaderTest()
{
Title = "test";
Width = 300;
Height = 300;
ListView lv = new ListView();
GridView gv = new GridView();
lv.View = gv;
GridViewColumn col1 = new GridViewColumn();
GridViewColumn col2 = new GridViewColumn();
col1.Width = col2.Width = 150;
col1.Header = "col1";
col2.Header = "col2";
gv.Columns.Add(col1);
gv.Columns.Add(col2);
Content = lv;
//GridViewColumnHeader h = new GridViewColumnHeader();
AddHandler(GridViewColumnHeader.ClickEvent, new
RoutedEventHandler(GridViewColumnHeader_Click));
}

void GridViewColumnHeader_Click(object sender, RoutedEventArgs
e)
{
string strMessage = string.Format("sender type= {0}
\nSource= {1} \nOriginalSource= {2} \nRoutedEvent Name= {3}
\nRoutedEvent Name= {4}",
sender.GetType(), e.OriginalSource,
e.Source, e.RoutedEvent.Name, e.RoutedEvent.RoutingStrategy);
MessageBox.Show(strMessage);
}
}
}
My System SpecsSystem Spec
Old 11-07-2006   #5 (permalink)
Bob
Guest


 

RE: How to specify an event handler for the GridViewColumnHeader contr

In article <FF7A9030-14F8-49C5-BFC7-E16D34993EC9@microsoft.com>,
RobinDavies@discussions.microsoft.com says...
> this.AddHandler(
> GridViewColumnHeader.ClickEvent,
> new RoutedEventHandler(MyHandlerFunc)
> );
>
>
> "wackyphill@yahoo.com" wrote:
>
> > I know its this for XAML:
> > <ListView GridViewColumnHeader.Click="MyHandlerFunc"/>
> >
> > But how do you specify an event handler for the GridViewColumnHeader
> > control in C#?
> >
> >

>


I messed with this for a while and saw that it was already answered by
Robin. But, I don't see GridViewColumnHeader as a member of ListView or
GridView... I originally instantiated a new instance of
GridViewColumnHeader in my code (below) but noticed the code works
without that line. Where's GridViewColumnHeader from?

-- sorry for wordwrap---

using System;
using System.Windows;
using System.Windows.Controls;

namespace Test.GridViewColumnHeaderTest
{
class GridViewColumnHeaderTest : Window
{
[STAThread]
public static void Main()
{
Application app = new Application();
app.Run(new GridViewColumnHeaderTest());
}
public GridViewColumnHeaderTest()
{
Title = "test";
Width = 300;
Height = 300;
ListView lv = new ListView();
GridView gv = new GridView();
lv.View = gv;
GridViewColumn col1 = new GridViewColumn();
GridViewColumn col2 = new GridViewColumn();
col1.Width = col2.Width = 150;
col1.Header = "col1";
col2.Header = "col2";
gv.Columns.Add(col1);
gv.Columns.Add(col2);
Content = lv;
//GridViewColumnHeader h = new GridViewColumnHeader();
AddHandler(GridViewColumnHeader.ClickEvent, new
RoutedEventHandler(GridViewColumnHeader_Click));
}

void GridViewColumnHeader_Click(object sender, RoutedEventArgs
e)
{
string strMessage = string.Format("sender type= {0}
\nSource= {1} \nOriginalSource= {2} \nRoutedEvent Name= {3}
\nRoutedEvent Name= {4}",
sender.GetType(), e.OriginalSource,
e.Source, e.RoutedEvent.Name, e.RoutedEvent.RoutingStrategy);
MessageBox.Show(strMessage);
}
}
}
My System SpecsSystem Spec
Old 11-07-2006   #6 (permalink)
wackyphill@yahoo.com
Guest


 

Re: How to specify an event handler for the GridViewColumnHeader contr

Indeed, it is kind of a mystery to me.
Thanks for the info Bob.

My System SpecsSystem Spec
Old 11-07-2006   #7 (permalink)
wackyphill@yahoo.com
Guest


 

Re: How to specify an event handler for the GridViewColumnHeader contr

Indeed, it is kind of a mystery to me.
Thanks for the info Bob.

My System SpecsSystem Spec
Old 11-07-2006   #8 (permalink)
wackyphill@yahoo.com
Guest


 

Re: How to specify an event handler for the GridViewColumnHeader contr

What concerns me most about it is I am unsure how to determine which
listview control is actually being clicked as the original source is
not the ListView.

My System SpecsSystem Spec
Old 11-07-2006   #9 (permalink)
wackyphill@yahoo.com
Guest


 

Re: How to specify an event handler for the GridViewColumnHeader contr

What concerns me most about it is I am unsure how to determine which
listview control is actually being clicked as the original source is
not the ListView.

My System SpecsSystem Spec
Old 11-07-2006   #10 (permalink)
Bob
Guest


 

Re: How to specify an event handler for the GridViewColumnHeader contr

In article <1162910700.953911.243530@i42g2000cwa.googlegroups.com>,
wackyphill@yahoo.com says...
> What concerns me most about it is I am unsure how to determine which
> listview control is actually being clicked as the original source is
> not the ListView.
>
>


It is a ListView (the Source, not OriginalSource). I had a small error
in the string.format... try this handler...

void GridViewColumnHeader_Click(object sender, RoutedEventArgs
e)
{
string strMessage = string.Format("sender type= {0}
\nSource= {1} \nOriginalSource= {2} \nName= {3} \nRoutedEvent
RoutingStrategy= {4}",
sender.GetType(), e.Source,
e.OriginalSource, e.RoutedEvent.Name, e.RoutedEvent.RoutingStrategy);
if (e.Source is ListView)
{
ListView l = e.Source as ListView;
string s = l.Name;
}
MessageBox.Show(strMessage);
}
My System SpecsSystem Spec
Closed Thread

Thread Tools
Display Modes



Similar Threads
Thread Thread Starter Forum Replies Last Post
Questions about delegate and event handler Curious .NET General 3 04-23-2008 10:26 AM
Make Non Microsoft mail handler the default mail handler Eddie Vista General 7 05-29-2007 06:06 PM
Windows Event Log fails to translate event description. Deepak Jha Vista General 0 12-15-2006 06:30 AM


Vistax64.com is an independent web site and has not been authorized,
sponsored, or otherwise approved by Microsoft Corporation.
"Windows Vista", the Start Orb, and related materials are trademarks of Microsoft Corp.
© Designer Media 2005-2008

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51