how to put multiple controls at the same position - c#

I want to show some info about a merchant. I want to put an logo image and a textbox at the same position. If the merchant has a logo, I'll show the logo image, hide the textbox. If the merchant doesn't have a logo, I'll show the merchant name in textbox and hide the logo image. How can I do that in xaml? Thanks!

You can use Grid Control for that. Place multiple controls inside exact same Column and Row. Then use show hide to display one and hide another.
To show and hide controls use the Visibility property of the control

if you are working on WPF application
You can make use of WPF canvas control and in that make use of z-index property to show hide your control.
check this for detail : Controlling z-order using the ZIndex Property

Related

Adding array of "Picture Box" to List Control

Friends,
How to add Array of PictureBox controls to the Listbox ? My requirement is to display N number of images from the directory to the PictureBoxes on Windows form.
I am able to generate N number of picture boxes dynamically, but how to add them in a listbox control with scroll bar option.
I cannot use ListView as the image size limitation is only (256,256)
Please suggest some option to achieve it.
Regards,
VHK
ListBox doesn't accept child controls. What you can do is:
Add the Images to the ListBox.Items directly (or wrap them in a helper class if you want to add ie. the filename of the image)
Set the DrawMode to OwnerDrawFixed
Handle the DrawItem event to paint the corresponding image

Embed a control inside a Tooltip in WinForms

is it possible to add a control to a tooltip?
What im trying to achieve is a tooltip that shows some example data in a dataGridview inside the tooltip.
What I have done so far is the following:
I have created a table with some settings (dataGridview with Name (text), Type (text), Example (image), and Setting (comboBox).
I managed to show a tooltip with the example as string onMouseOver the example image.
I'd like to embed another dataGridview in the tooltip because some examples are in table form.
Tooltips are very limited.
The solution is to create a custom tooltip. You do a form and make it look like a tooltip and you put on it what you want.
You can make it look exactly like a tooltip an you can show it and hide it with the event handlers on your datagrid.
My solution was to use a custom panel that shows up on the cursors position and fade out after a timer has reached end.

How can I custom an editable container panel control in wpf?

I am trying to custom an editable container panel control like below in wpf.
The container panel control is an parent control that chould contains any other control and it is an editable control.It displays a plus icon with blank space when the panel control did not contain any control.User could click the panel which displays a plus icon to add any control to the panel.User could remove the control by floating bar which contains in the panel control.
Is there anybody could tell me what the name of this kind of control panel?And how can I achieve it in wpf?Any clue?
Thank you!
Try take alook at This,It should helps.

increase User control size while re-sizing Form

I have an application based on two user controls and one form. This form is parent to my 2 user controls and i pragmatically add them to the form. My issue here is that when anchor components in the user control, they are not anchored in the form. So when re-sizing the form by dragging one of the corners, it seems like the user control does not also get re-sized. I was told that i had to listen to the Forms size and append that size to the User control. Is that a good solution? if yes how would i do that?
My user controls are inserted in a tab component btw.
This is my code for adding the user controls to the form. (if it is needed)
public void addUC(UserControl control, TabPage tab)
{
control.Parent = tab;
}
can anyone help ?
You might want to anchor the child usercontrols using the Anchor property.
If there are only 2 use controls in the form why not use dock - it will always stretch the use control to the maximum size of the form

How do I keep my winforms controls from overlapping when I expand the application?

I have a pretty simple winforms application. It contains a rich edit box, embedded browser, progress bar, a few buttons etc.
I have the anchors on the controls set to expand in all directions.
When expanding up and down, however, the controls will overlap one another. How do I prevent this from happening?
Thanks
Your best bet is to add a TableLayoutPanel to your form which contains the "layout grid" this should be docked to the form, then you can add your controls into the cells in the table (they can cover multiple rows and columns so you can get the layout you want).
You must set the property Autosize=true on every control, especially on the main form.
Note that some controls like TabControl have this property, but you can't see it with intellisense (Attribute Browseable=false).

Categories

Resources