I am creating a group of panels with labels in it. Depending on the requirement of the User. Kind of mimicking the Tab control here. Where like the Tab control's Title is editable, i would let the user to configure the name of the labels at design time. How possibly can i achieve it?
In the event Handler of the Label, change the label to a TextBox. When the TextBox looses focus, replace it with a Label again
Please chehk the following thread (Header Editable Tab Control in WPF).
If you use WPF, then this is exactly what you need for your work. If you use another template, maybe still can add some tips. :)
Good luck
Related
I have created a Windows form using a Tab Control, but it has a header with it. I want to hide it. I am not able to do it using any properties of the Tab Control. Is there any property defined for hiding the tab header for the Tab Control without going through the code?
Use following code to hide the tabs or set these properties in design.
tabControl.Appearance = TabAppearance.FlatButtons;
tabControl.ItemSize = new Size(0, 1);
tabControl.SizeMode = TabSizeMode.Fixed;
You want the tab panels without the feature allowing a user to switch between them, so I suppose you want to create few separate sets of controls to be shown to the user one at a time. You can achieve this in several ways (you can choose one of them if you find it appropriate in your case):
Use several Panel controls instead of several tabs in the TabControl, however, it would be hard to work in the designer, because all the controls would be visible
Use different Forms instead of tabs to keep the layout parts separated. It can be ok, but you may not want to use multiple Forms, so it depends on a specific case.
and finally, the suggested solution:
Encapsulate each set of controls in a UserControl. This allows you to keep each layout separately, so you can easily design each of them without the other controls getting in the way ;). The the code handling each of the layouts would also be separated. Then just drag those controls in the Form and use set their visibilities appropriately to show the one you want.
If none of those suggestions work for you, let me know, so I can look for other possible solutions.
It's more easy as you think, you just drag the panel's window upper, so will be outside of the form.
Use DrawMode: OwnerDrawFixed will hide TabPage header text DrawMode : OwnerDrawFixed
Another way to achieve the same (or similar) is: You can remove tabs from TabControl.TabPages collection and then add the tab you want to show.
During the Form initialization I remove tabs (so into the designer I can easily manage them) and in some control event (as button click) I show the tab the user has to see.
Something like that:
// During form load:
ctrTab.TabPages.Clear();
// ......
// During button click or some other event:
if(rbSend.Checked)
ctrTab.TabPages.Add(pgSend);
else
ctrTab.TabPages.Add(pgReceive);
In this way the user can still see the header tab but just as title of controls group, he can't change/switch the current active tab.
So im making a WPF project where one of my windows has to let the user see a text. Select parts of this text for being put into an array of strings and no more than that. So he/she musnt be able to edit anything in the text only highlight parts and then click on a button. What WPF control would be smart to use for this?
I'd probably just use TextBox with IsReadOnly set. The various selection properties are all you need after that.
I would like to create a listbox, with a details pop-up/tooltip kind of window.
Scenario is as following:
List of items
Show details of selected item
Details should be displayed outside the listbox and overlaying any controls that happens to be nearby.
The problem about using tooltips is that they disappear after a while. And the problem about using pop-ups is that they do not move, when the window moves (?)
So I'm just looking for some pointers on how to solve this.
Use ToolTip object. It has autopositioning and nice graphical style out of the box.
Simply use it like this:
toolTip.PlacementTarget = yourSelectedItem;
toolTip.Placement = PlacementMode.Right;
toolTip.Content = {place whatever you need to display here};
You can control its visibility with the IsOpen property.
Adorners were built for things like these.
That said, if I were doing this I would set "StaysOpen" on a Popup to false. So when the user clicks somewhere else it will automatically disappear (ie when window is moved). Do you really see your users moving the window so often while looking at the details? Going down the adorners route is not all that easy. It has its own complications.
I have what I consider to be a pretty unique problem here, and no idea how to implement. From what I've seen, there is no documentation, tutorials, samples and/or articles on this. I've spent weeks researching, with nothing to show.
The problem:
I need the user to be able to select the contents of a Label Control at runtime, and edit it.
If this can be done by extending the existing Label control, great! Or, if this requires a whole new Label Control to be created, fine. So be it.
Using a TextBox is not an option I'm afraid.
Any help at all is greatly appreciated!
Thank you,
jase
If it's just because a look & feel issue you can make a TextBox control look the same as a label would looks like (just guessing since I can't imagine any reason for not using a TextBox).
Could you pop up a window with a text box in it and then have them edit it there, then set the text property of the label based on the edited text box or do you need to edit it in place? You can set the label text at runtime, but for user input you will have to use a text box.
how do i highlight the selected item (in my case, a custom user control) in a flowlayoutpanel
FlowLayoutPanel is purely for layout - it has no concept of a "selected item". You might be able to add some logic to your UserControl which changes its colour when it receives focus (and changes back when it loses focus) but that would be independent of the layout control that's hosting it.
I created a Bindable FlowLayoutPanel that included setting the selected index (with highlighting depending on the selected control. I posted it over on the code review site. Check it out and let me know if that works for you.
Check this implementation, Through event handling