Disable Gridview position change on navigateback - c#

How to disable the scrolling on my gridView? When i click the back button after modifing my selected item.
as example u can create a default grid app
if you created a app based on this template and now select the a item in the last list and then click the back button it will scroll to the beginning. But it should stay over the last list.

When you goBack() a new instance of the first Page is created, that's what causes the lost of your scrolling, to fix that make sure that the first Page is cached so you will navigate back to the same instance using NavigationCacheMode
NavigationCacheMode="Enabled"

Related

Is it possible to pass listBox selected Items from one wpf page to another

I am trying to select multiple items on a listbox and when a button is pressed those items get moved to another listbox on a separate page. Perhaps i need to use serialization or a storage folder?
If both pages are opened by the same application, you can just have a property in one of the pages, which will reference the property in the other page and some event, that will fire on when the button will be pressed.

DropDownList after reset button c#

I have a c# dropdownlist inside a form. My goal is to hit a reset button and set the entire page back to the way it was when I first loaded the page. My textboxes are clear and everything is where it should be except my dropdownlist. It displays the last selected dropdownlist Item selected. I would like it to go back to the initial selection when I reload the page. How would I do this?
DropDownList1.ClearSelection();
or
DropDownList.Clear();
Doesn't work
DropDownList1.SelectedIndex= -1

DataGridView cannot be Focused, but one of them can

I've come across the strangest bug pertaining to DataGridViews in Windows Forms.
I have a TabControl, that is supposed to contain a docked DataGridView in each tab page. I thought it would be convenient that the grid is focused upon changing the tab page, so that the user could simply hover the mouse over the grid and start scrolling when he changes the page. So, I just put a grids[tabs.SelectedIndex].Focus() in the event handler for changing the tab page.
However, something really strange happened. In my test application, I have three tab pages. If I try scrolling the grid right after starting the application, it doesn't work; I have to click in the grid first. I was expecting this. However, if I change the tab page, I can't scroll in any of the other grids until I click, except for the first one!
So, if I switch pages to the second page, then back to the first, I can automatically scroll that grid without clicking, but if I then switch to the third, I have to click for the grid to focus.
I had a look at the CanFocus properties of the grids, and it seems that only the first grid has it set to True. They are all created programmatically, and all in the same way. I don't see why they would be different.
Any ideas?
Inactive tab pages have their Visible property set to false. The documentation for CanFocus says:
In order for a control to receive
input focus, the control must have a
handle assigned to it, and the Visible
and Enabled properties must both be
set to true for both the control and
all its parent controls
Well, I solved it. Stupid programming error on my part, I had grids[tabs.TabIndex].Focus() instead of grids[tabs.SelectedIndex].Focus().
Oh well.

How to Set Up Winform Textbox Field Focus so a User Can Go Through Them by Clicking Tab Button?

UI is created in VS 2008. I'm using C# .... I need to let the user move/focus between text fields from top to bottom by clicking tab button. How can i do it?
On the Layout toolbar (will normally show up if you're in Design View) click on the buttom on the most right (it's called tab order).
Now on every element on your designer will come up a little box with a number. Just click all your elements in the order you like and they will automatically be re-ordered.
If you like to do it manually, just take ho1 advice and change the property manually.
You just set up the TabIndex property properly, so that it's sequential from top to bottom. Then it'll work automatically and you won't need any code to move around the focus.
So in other words, set the top TextBox TabIndex to 1, the next one you set to 2 etc and then one at the bottom will have the highest number (of the textboxes, you probably want to have even higher indexes for any OK buttons and similar so that the user can jump to them after editing all the textboxes).
You can find more info about it here:
http://msdn.microsoft.com/en-us/library/system.windows.forms.control.tabindex.aspx

ASP.NET page won't remove UI elements

I'm working with an aspx page, where once I click on a button, some calls are executed in the background and I display the returned information on the webpage. I do this by adding this information to a panel:
panel.controls.add(label)
panel.controls.add(anotherpanel)
Problem is that once I click the button again, and I get some new objects from the background calls the UI elements (those labels and panels) still remain visible and my new information is just added after the previous one.
I would like to have all the previous information gone once I press the new button.
I've tried panel.controls.clear(), but it doesn't do anything.
Any ideas? Thanks.
Have you tried setting a breakpoint and check to see that it is not the background calls returning the previous information along with the new ones?
I asked because items that were added programmatically, by itself, shouldn't persist across postbacks.
You might want to declare label and anotherpanel in the actual markup, and set their visibility to false. Then, just set the visibility to true and replace their values in your codebehind as you acquire results.

Categories

Resources