From: Mesalem on 8 Feb 2005 06:47 I have a datagrid derived class where i want to scroll the horizontal scroll bar to the right. i tried the following code: HScrollBar sb = (HScrollBar)base.GetType().GetField("m_sbHorz", BindingFlags.NonPublic|BindingFlags.GetField|BindingFlags.Instance).GetValue(this); sb.Value=5; but i received a NullReferenceException in System.Windows.Forms.DataGrid.Dll, I tried the following code and the same exception happened HScrollBar sb = (HScrollBar)base.GetType().GetField("m_sbHorz", BindingFlags.NonPublic|BindingFlags.GetField|BindingFlags.Instance).GetValue(this); System.Reflection.PropertyInfo pi=sb.GetType().GetProperty ("Value",BindingFlags.Public | BindingFlags.Instance ); pi.SetValue (sb,90,null); any suggestions??
From: Sergey Bogdanov on 8 Feb 2005 07:04 Instead of base.GetType().GetField(...) use: typeof(DataGrid).GetField(...). Best regards, Sergey Bogdanov http://www.sergeybogdanov.com Mesalem wrote: > I have a datagrid derived class where i want to scroll the horizontal scroll > bar to the right. i tried the following code: > > HScrollBar sb = (HScrollBar)base.GetType().GetField("m_sbHorz", > BindingFlags.NonPublic|BindingFlags.GetField|BindingFlags.Instance).GetValue(this); > sb.Value=5; > > but i received a NullReferenceException in System.Windows.Forms.DataGrid.Dll, > I tried the following code and the same exception happened > > > HScrollBar sb = (HScrollBar)base.GetType().GetField("m_sbHorz", > BindingFlags.NonPublic|BindingFlags.GetField|BindingFlags.Instance).GetValue(this); > > System.Reflection.PropertyInfo pi=sb.GetType().GetProperty > ("Value",BindingFlags.Public | BindingFlags.Instance ); > > pi.SetValue (sb,90,null); > > > any suggestions?? > > >
From: Mesalem on 8 Feb 2005 10:07 i found the bug it was initialization problem, thanks for the reply Does anyone know how to do this in a listview?? "Sergey Bogdanov" wrote: > Instead of base.GetType().GetField(...) use: > typeof(DataGrid).GetField(...). > > Best regards, > Sergey Bogdanov > http://www.sergeybogdanov.com > > > Mesalem wrote: > > I have a datagrid derived class where i want to scroll the horizontal scroll > > bar to the right. i tried the following code: > > > > HScrollBar sb = (HScrollBar)base.GetType().GetField("m_sbHorz", > > BindingFlags.NonPublic|BindingFlags.GetField|BindingFlags.Instance).GetValue(this); > > sb.Value=5; > > > > but i received a NullReferenceException in System.Windows.Forms.DataGrid.Dll, > > I tried the following code and the same exception happened > > > > > > HScrollBar sb = (HScrollBar)base.GetType().GetField("m_sbHorz", > > BindingFlags.NonPublic|BindingFlags.GetField|BindingFlags.Instance).GetValue(this); > > > > System.Reflection.PropertyInfo pi=sb.GetType().GetProperty > > ("Value",BindingFlags.Public | BindingFlags.Instance ); > > > > pi.SetValue (sb,90,null); > > > > > > any suggestions?? > > > > > > >
From: Sergey Bogdanov on 8 Feb 2005 10:21 You may consider EnsureVisible method and if you would like to scroll to the end of the list then call the method with "listView.Items.Count - 1". Best regards, Sergey Bogdanov http://www.sergeybogdanov.com Mesalem wrote: > i found the bug it was initialization problem, thanks for the reply > Does anyone know how to do this in a listview?? > > "Sergey Bogdanov" wrote: > > >>Instead of base.GetType().GetField(...) use: >>typeof(DataGrid).GetField(...). >> >>Best regards, >>Sergey Bogdanov >>http://www.sergeybogdanov.com >> >> >>Mesalem wrote: >> >>>I have a datagrid derived class where i want to scroll the horizontal scroll >>>bar to the right. i tried the following code: >>> >>>HScrollBar sb = (HScrollBar)base.GetType().GetField("m_sbHorz", >>>BindingFlags.NonPublic|BindingFlags.GetField|BindingFlags.Instance).GetValue(this); >>> sb.Value=5; >>> >>>but i received a NullReferenceException in System.Windows.Forms.DataGrid.Dll, >>>I tried the following code and the same exception happened >>> >>> >>>HScrollBar sb = (HScrollBar)base.GetType().GetField("m_sbHorz", >>>BindingFlags.NonPublic|BindingFlags.GetField|BindingFlags.Instance).GetValue(this); >>> >>>System.Reflection.PropertyInfo pi=sb.GetType().GetProperty >>>("Value",BindingFlags.Public | BindingFlags.Instance ); >>> >>>pi.SetValue (sb,90,null); >>> >>> >>>any suggestions?? >>> >>> >>> >>
From: Mesalem on 9 Feb 2005 04:21 this method will scroll the listview top or down (vertical), what about scrolling to the right or the left (horizonal)?? "Sergey Bogdanov" wrote: > You may consider EnsureVisible method and if you would like to scroll to > the end of the list then call the method with "listView.Items.Count - 1". > > Best regards, > Sergey Bogdanov > http://www.sergeybogdanov.com > > > Mesalem wrote: > > i found the bug it was initialization problem, thanks for the reply > > Does anyone know how to do this in a listview?? > > > > "Sergey Bogdanov" wrote: > > > > > >>Instead of base.GetType().GetField(...) use: > >>typeof(DataGrid).GetField(...). > >> > >>Best regards, > >>Sergey Bogdanov > >>http://www.sergeybogdanov.com > >> > >> > >>Mesalem wrote: > >> > >>>I have a datagrid derived class where i want to scroll the horizontal scroll > >>>bar to the right. i tried the following code: > >>> > >>>HScrollBar sb = (HScrollBar)base.GetType().GetField("m_sbHorz", > >>>BindingFlags.NonPublic|BindingFlags.GetField|BindingFlags.Instance).GetValue(this); > >>> sb.Value=5; > >>> > >>>but i received a NullReferenceException in System.Windows.Forms.DataGrid.Dll, > >>>I tried the following code and the same exception happened > >>> > >>> > >>>HScrollBar sb = (HScrollBar)base.GetType().GetField("m_sbHorz", > >>>BindingFlags.NonPublic|BindingFlags.GetField|BindingFlags.Instance).GetValue(this); > >>> > >>>System.Reflection.PropertyInfo pi=sb.GetType().GetProperty > >>>("Value",BindingFlags.Public | BindingFlags.Instance ); > >>> > >>>pi.SetValue (sb,90,null); > >>> > >>> > >>>any suggestions?? > >>> > >>> > >>> > >> >
|
Pages: 1 Next: DataGrid only displays header cells |