Drag and Drop control from toolbox not working - c#

In windows form application, i created a usercontrol page. Here, I need to add a myowncontrol from tool box.
I just added myowncontrol in the tool box. by the way of browsing dll and placed it in tool box.
Here, when i drag and drop any one of default control, which can easily dragged and placed in the usercontrol page. But when i try to drag and drop myowncontrol into usercontrol page , its not working.
Can't able to drag and drop.
(i mean i can pick the control from the tool box but i can't able to place it where i want)
what is the problem in my area?

I'll admit that this does not directly answer your question, but I am wondering if you have tried to programmatically add the control to a Form? You would need to add a reference to the DLL that contains the UserControl and then do something similar to below in your source code.
var myCtrl = new MyControl(); //your UserControl class here
myCtrl.Location = new Point(25,25); //give it a location
this.Controls.Add(myCtrl); //add it
Also another thought... Are you sure that it's not really being added and it's just not visible? For a Form or UserControl in the Visual Studio Properties Window there is a drop-down at the top which contains all the controls that have been added.

Related

How can I add controls to a tab control that is inside of a custom control, at design time?

I have a custom control that is made up of two main controls, a FlowLayoutPanel on the left side, and a TabControl on the right side. The FLP is just used to store custom "buttons" that change the selected index of the tab control. I have it working at design time so that I can select the buttons and move through the pages.
I'm trying to make it so that I can drag controls to those pages, but the controls are just being added to the custom control.
Any ideas on how to accomplish this task?

tooltip text property on user controls of system windows forms missing

After using C# a while, I recognized that the user controls of system windows forms don't provide a tooltiptext property like I am knowing it from Visual Basic 6.
I saw that the Form, TextBox, Label, ComboBox and PictureBox don't have such property.
Now I have the curious question:
How would I display a tooltip to the user on mousehover over a control like the above mentioned?
And Yes, I saw the "tooltip" control in the toolbox. It provides a baloon and I do not need a baloon.
It shows the tooltip for one item only once per user session and then never (known problem of the component) and why I would need an extra component, if this should be just a property of the corresponding control, for which I would like to provide a tooltip like TextBoxes, Labels etc.
And Yes, I saw the "Help Provider". I have usually never a help file assigned with my projects,
so I do not use the Help System. What I need is a simple Tooltiptext, not a "F1 component".
Now I am curious, how I would implement a Tooltiptext if the controls don't provide a option for it.
Can it be, that C# has no control tooltips? Even Delphi has! Or have I missed something somewhere?
The solution:
Delete all notifyicon controls from your project to ensure no unwanted info bubbles appearing
in the system tray.
Drag and Drop the Tooltip Component in Toolbox on your form, but ignore all the baloon properties and the baloon timeout properties and baloon timer properties, just Drag and Drop
the component without further action.
A weird new property field "tooltip on tooltip1" shows now up in all TextBoxes and Labels etc. on the form.
Just handle this field as it would be your Tooltip property and don't setup anything else in code
or on the designer. Build and compile. The tooltiptext will now show up as normal tooltip without
baloon functionality.
It sounds like you are using the ToolTip control incorrectly.
1- Drag it from the toolbox to your form.
At this point, each control on the form now gets a property "Tooltip" to set the appropriate text.
2- Set each control's new "ToolTip" property in the way you find most intuitive.

How do I create a Tab Control with no Tab Header in Windows form?

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.

Code for drag and drop c# controls in to a form

i want a code snippet for dragging controls and dropping them to a Panel and placing them back...as needed.how can i get the controls property same as used in vs,i am using vs2010 and c# web application.i want the functionality to be as in as when we design a form.pls help..
Create the control in a projetct with add to solution --> user control or component
Add the control to the toolbox via the Context Menu-->choose Items and select your control (do not forget to compile once finished ;-) )
All public properties will be available to edit in VS, there are also some attributes to control acces to the properties (but I can't remember them now).
hth
Mario

Repeat a user control as user clicks next?

I have a user control that consists of some textboxes and checkboxes. Once the user is finished filling the first one, they should be able to add one more form by clicking an "add another record" link button.
How can I repeat this usercontrol as the user clicks?
I am supposed to use C# only.
So, we are talking of UserControl where your fields are located (I mean, that this is a one class inherited from UserControl or Control. )
There are a lot of ways to do it. But, I think, to be mode 'code concise' is to use FlowLayoutPanel
a) Create this panel. (through visual designer i.e.)
b) When user clicks, create your control
c) add your control to layout panel.
var myControl = new MyControlWithForm();
flowLayoutPanel1.Controls.Add(myControl);
One could use flowLayoutPanel1.Controls array to process all filled forms afterwards.

Categories

Resources