![]() |
![]() | ![]() | ![]() | ![]() | ![]() | ![]() | ![]() |
|
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.
br> br> |
| |||||||
![]() |
| | Thread Tools | Display Modes |
| | #1 (permalink) |
| 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 Specs![]() |
| | #2 (permalink) |
| 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 Specs![]() |
| | #3 (permalink) |
| 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 Specs![]() |
| | #4 (permalink) |
| 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 Specs![]() |
| | #5 (permalink) |
| 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 Specs![]() |
| | #6 (permalink) |
| 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 Specs![]() |
| | #7 (permalink) |
| 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 Specs![]() |
| | #8 (permalink) |
| 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 Specs![]() |
| | #9 (permalink) |
| 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 Specs![]() |
| | #10 (permalink) |
| 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 Specs![]() |
![]() |
| 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 |