|
ms
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
Why won't you give me your scrollbars?! I hate you, TreeView!A little dramatic maybe, but I've just finished my pass on the "UI Polish"
and only one things remains (well, I guess I haven't finished then!) Vertical Scrollbar position. Doh! Part of my code clears a Node's nodes, then rebuilds them all. When this happens, the scrollbar position is not restored (expected - I'm happy to do it.. if I can!) and I don't see how I can do that. I have checked the docs, google, friends, etc. No love. Is it possible? Teach me, wise one(s)... sklett wrote:
> A little dramatic maybe, but I've just finished my pass on the "UI Set 'EnsureVisible' on the treenode to true. > Polish" and only one things remains (well, I guess I haven't finished > then!) > > Vertical Scrollbar position. Doh! > Part of my code clears a Node's nodes, then rebuilds them all. When > this happens, the scrollbar position is not restored (expected - I'm > happy to do it.. if I can!) and I don't see how I can do that. I > have checked the docs, google, friends, etc. No love. Is it > possible? > > Teach me, wise one(s)... FB -- ------------------------------------------------------------------------ Lead developer of LLBLGen Pro, the productive O/R mapper for .NET LLBLGen Pro website: http://www.llblgen.com My .NET blog: http://weblogs.asp.net/fbouma Microsoft MVP (C#) ------------------------------------------------------------------------ > Thanks for the post!> Set 'EnsureVisible' on the treenode to true. This doesn't work. Not for my case. I need to get and restore the scrollbar position. Show quoteHide quote > > FB > > -- > ------------------------------------------------------------------------ > Lead developer of LLBLGen Pro, the productive O/R mapper for .NET > LLBLGen Pro website: http://www.llblgen.com > My .NET blog: http://weblogs.asp.net/fbouma > Microsoft MVP (C#) > ------------------------------------------------------------------------ I had a similiar issue in a datagrid which I had to remember the value
and find it again. The scroll isn't readily available so I had to override the normal grid to make the scroll accessible... // When the frmEditShipment form closes, it will set the // lastEvent and lastRecord strings so that we can // this form can autonavigate to the record and re-select it. // this way, even having several records open you can // close anyone and be brought to it's matching line entry. if(lastEvent == "Edit") { //lastEvent = ""; runData(true); // runData has reset the grid, due to rebinding // now set the grid back to the same location // the BindingManagerBase gives you a link between // the displayed records and the dataset records. // use this to scroll to and select the row BindingManagerBase bmb = dgRec.BindingContext[dgRec.DataSource,"trucks"]; for(int i = 0; i < bmb.Count;i++) { // use the Manager as a cursor and move forward through it. bmb.Position = i; // check each row's barcode to see if it's the right one DataRow dr = ((DataRowView)bmb.Current).Row; if(lastRecord == Convert.ToString(dr["barCodeNumber"])) { // had to override the grid to get access to the scroll // also had to use the overridden object as the grid, // instead of the default Forms.DataGrid // It now exists in MyDataGrid.cs dgRec.ScrollToRow(i); dgRec.CurrentCell = new DataGridCell(i,1); dgRec.Select(i); break; // don't look anymore } } } Maybe something similiar will help you get it working... public class MyDataGrid : DataGrid { public MyDataGrid() { // // TODO: Add constructor logic here // This class is dirived from DataGrid to all // the private method GridVScrolled to be // accessed, allowing us to scroll the grid // back to it's last row after a refresh // of the data and a rebinding // } public void ScrollToRow(int row) { if(this.DataSource != null) { this.GridVScrolled(this,new ScrollEventArgs(ScrollEventType.LargeIncrement,row)); } } }
Other interesting topics
Effective strategy for using VSS in a development team?
How to set build order? Getting Event of Lock Windows OS Application Idle - Good or bad practice? How to: Access the Managed HTML Document Object Model Getting text box value on key press? Finding if a column is unique in a dataset Visual C# FileIO and Environment Permission PP: Identifying list of unwanted USINGs PP: Orphan Assemblies List |
|||||||||||||||||||||||