Suppose I have an ajax TabContainer with two tabs. Due to certain buisness logic, we might set one of the tabs to Visible = false.
In this scenario, is it possible to hide the TabStrip at the top, so that they don't see only one tab?
OK; didn't get any replies, but just wanted to summarize what I was able to do:
For the above situation, I actually was able to move the contents of the one visible tab outside the container by reassigning its parent control, and then re-adding where it needed to go (my example is a little more complicated than usual, due to update panels being in the section of code getting moved)
However, it does seem possible to hide the TabStrip by modifying its CSS class depending on how many tabs should be displayed. See http://www.krissteele.net/blogdetails.aspx?id=117 or http://cushen.wordpress.com/2007/10/25/how-to-styling-the-asp-net-ajax-tabcontainer-control/ for some examples of how to modify the styling.
Related
I'm trying to add a panel on two different panels in this way:
_formMain.panel3.Controls.Add(_formMain.panel1);
_formMain.panel4.Controls.Add(_formMain.panel1);
What I obtain is that panel1 is added only to panel4 and it is removed from panel3.
It seems that the latest "Add" overwrites the others "Add". Is it true?
Why? How can I add the same panel to some differents controls?
Thank you
Your title says it all:
There is only one control and it can only be in one place, read it can only have one parent.
Therefore, if you change the Parent or Add it to another Control's Controls collection, which is ecxactly the same thing, it will disappear from the previous place.. So while Add doesn't sound like it, it amounts to a Move.
If you need more controls you need to create more controls! And of course they will be different Controls, with different properties and contents..
You can have more than one control show the same content if you keep them synch'ed. One prime example with automatic synchronizing would be two DataGridviews, both with the same DataSource. For other content, like Text or Images the syn'ching is up to you!
You may think about writing a clone function, that can create a deep copy but you will still have to do the syn'ing. This may be codeable as well, depending on the details.. Or you could make it into a UserControl and add fresh instances of it.
this is my second question regarding more or less the same topic, since I am still struggling with it.
This is the layout I need to build:
Also important:
The header and the footer contain buttons, info but shouldn't be included in the page transitions (eg. shouldn't fade in or fade out).
In the end I just want the controls inside the "Page w/ content" (see picture below) area to be animated (fade in/fade out, etc) between the different pages.
What I got so far:
Header and Footer are user controls;
Page w/ content is a Lockablepivot (with headers hidden), and I use the pivot items to switch between the different content I want.
Problems:
I havent been able to put the Islocked = true working (it always gives me a null ref excep);
A pivot item is not really a page, so If the user for presses the back button it leaves the app (I think I can probably solve this by overriding the back button etc..);
I don't know if its easy or even doable to change the pivot items animations (haven't researched much about this one).
Ok, so my real question:
What other options do I have?
Using a ContentPresenter in the "Page w/ content" area to show me another xaml page? I read something about this being not good at all;
Do everything in one page but dynamically and through the code add, delete, fade in, fade out all the controls ?
Any ideas? What about performance? Which one should perform best?
Thank you!
Put an Header and Footer controls to a each page and make any animations with Content control you like
In my previous question I could add a design time panel to a tab page at run time and my code looks like this and it works Ok.
tabControl1.SuspendLayout();
tabControl1.TabPages[0].Controls.Add(panel1);
tabControl1.ResumeLayout();
but now I need to do something like this:
tabControl1.SuspendLayout();
tabControl1.TabPages[0].Controls.Add(panel1);
tabControl1.TabPages[1].Controls.Add(panel1);
tabControl1.TabPages[2].Controls.Add(panel1);
tabControl1.ResumeLayout();
which just at run-time I can know how many of these Tabpages I will need. but now for testing I am assuming I will have three tabPages
the Problem is that the panel only gets added to the Last tabPage,
How can I fix this? I want it get added to all of the tab pages
Thanks.
You can't. A control can have only one parent at a time. Luckily, only one tab page is visible at a time, so I guess you could move the panel between the pages as they are displayed? On the other hand, if the panel is to be located in the same place for all pages, perhaps it should not be placed inside the tab control, but rather on top of it?
I'm just getting started with winforms in C# and things are going well, except I want to learn how to do something like:
if user presses "proceed" button, it will run some code, and change the form, so that there are more options available to the user on the form. In other words, I want to make my forms more than one "page". I hope that all makes sense. Any help would be appreciated, thanks!
You could have a tab control with separate tabs that you move through that are disabled until they are needed. Each one could have its own controls, etc... You could have the controls disabled on the main form and then enable them, etc... There are myriad ways that you could approach this problem.
For winforms:
private void button1_Click(object sender, EventArgs e)
{
textBox1.Visible = true;
}
One easy way of doing that is to add a container control, for example a GroupBox that contains a selection of controls that belongs together and then you make that GroupBox invisible. Then in the button click handler you make it visible again.
That way all the related controls are shown/hidden together and if needed you can move them around the screen without needing to worry about their locations related to each other.
I want to make my forms more than one "page"
When I do that, I normally build each "page" as custom control. This let's me separate the navigation elements from what it is you're navigating to, so that I can easily play with different ideas later. For example, do I want to use a tab control to host each page inside a separate tab? No bid deal - just drop one my controls on each tab. Swap out different pages on the same form? It's only one control to replace. Move between completely different forms? Still easy.
As a basic starting point, if you want to run some code when the user clicks the button just handle the Click event. Just double click the button to get to the code-behind and place your code in there.
In terms of exposing extra functionality when the user clicks proceed there are various options available to you, its really up to you to figure out which is best suited to your application. One simple option would be to perhaps have a Panel or GroupBox and place all the extra options on there and make it disabled, then enable when you see fit.
I'm using different sets of controls on the same location on a form. By default all are visible=false and then certain subsets of the controls are set to visible as the user selects specific values in a combobox dropdown control.
From the user's perspective this works well since they only see the controls that are needed.
However, since the controls occupy the same location on the form it is difficult to manage these in Visual Studio design view.
Is there a way to group sets of these overlapping controls in Visual Studio so that I can select the entire subset of controls quickly and easily? Is there a way to hide certain controls in design view? Right now everything is stacked on top of each other when developing so it makes managing these controls difficult.
To get such a beast to work i would put every group into it's own UserControl. On your MainForm you stack all these UserControls above each other.
So at the MainForm you can't really get a good overview, but now you got for every group your individual designer view and in your main form you can hide the complete group by a single line of code userControl.Visible = false.
A TabControl can do this, works well in design mode. You just need to hide the tabs at runtime. Check my code in this thread.
You can not hide them.
However you can group them in group box
and using "Bring to front" and "Send to back" property deal with them.
First of all,
If you work with multiple components in same location, you can use groupboxes in your form. Then, to superimpose these groupboxes, you should edit each of your groupboxes on different place in your form screen. After the edit, you should input size and location data manually in your groupbox properties menu.
If you want to edit one of your groupbox after the set location, you can easily right click any of your groupboxes then click "send to back" and "bring in front" commands. I hope it helps.