Displaying Ruler in visual studio 2010 - visual-studio-2010

Is there any way to display ruler or scale in visual studio designer mode? Actually I want a scale that will measure the vertical and horizontal space between the components (eg label, text box) and distance of those components from the form body. The scale or ruler will help to show the components with equal horizontal and vertical space in each form.

If I correctly understood, you need to control the distance of the components in a Window(Winforms).
For this, you can create a control class, this class will check the distances between components in your window and establish rules of location for each component on run time.
For control each component you can use this:
For Each ctrl As Control In Me.Controls
If TypeName(ctrl) = "TextBox" Then
If Not ctrl.Width = 0 Then
MsgBox(ctrl.Name)
'Do Something
End If
End If
Next
This rules of location can be applied on your window "load" event
You can learn more about location of component through this links:
https://msdn.microsoft.com/en-us/library/system.windows.forms.control.location(v=vs.110).aspx
Changing the location of a control on a windows form programatically using VB.net?
PS. You can see I use vb,net language examples but this can be easily converted to C# or other language.

Related

How to place a windowless control on top of a windows control?

Say, I have an Image control (which seems to be a window-less control) and I want to make sure that it is on top of a TextBox. No matter what I do, the Image control will not appear on top of the Text box.
Is there a way?
P.S. I know I can use a PictureBox, but it does not support transparency, thus I must have the Image control.
There is no way to place an image control over a normal textbox as they are drawn onto the form itself so will always be below any other windowed components.
If you have VB6 installation media there are drawn (windowless) versions of controls including a TextBox you can use that will (probably) do what you want; http://support.microsoft.com/kb/184687
A custom usercontrol of some kind if probably better .. what is it exactly you want to overlay the textbox with?
The Image Control is considered a graphical control, like shapes, so it is always inferior to text controls. If you really want a transparent image, you can use a Microsoft 2.0 Form instead(only if you have it). Images there can be on top of textboxes, and you can make it transparent by setting the Backstyle to Transparent(0).
Completely different approach to my other answer (hence the seperate Answer), but you can set AutRedraw and ClipControls on your Form to false and it will allow the Image control to render on the same layer as a windowed control. You can get some flakey redrawing in some cases but for a quick solution you could try it.
http://msdn.microsoft.com/en-us/library/aa733621(v=vs.60)
I've created a tranparent overlay control to add a kind of annotation layer on top of a VB6 app. I'll attempt to describe it from memory, and if that doesn't provide enough information then you can post back and I'll try to dig up the code.
First, add a new USerControl to you application. Give it a name like ImageEx, PictureEx, or TransparntImage. There are several properties that you will need to use. Ensure the control is Windowed, so it can sit on top of other windowed controls. Locate the MaskColor property and set it to Cyan (or whatever color you elect to use to indicate a tranparent area. There might be an addition property enable the masking behavior, just browse the properties. Set the control background color to that of the MaskColor. At this point you have an invisible control. In my control I painted on top of the surface for annotations, but you can PaintPicture or maybe even set the image property for a really simple approach.
Of course, to make this a re-usable control, you will want to code in your own properties that allow the MaskColor and image, etc to be set so that you can the drop one of these on any form you want.
Some links:
MaskColor Property
MackPicture Property
1) Remove all your textboxes , labels and ... (But memorize their name and location in the form)
2) Go to (project > components) and mark the (Microsoft Forms 2.0 Object Library) then click ok
3) Now you can see new controls under your default controls in your toolbox...
4) Use its textbox and label controls instead of the default controls
5) Right click on your Image Control then click (Bring To Front)

Spacer between elements in visual studio

What shall i use to make a spacer between elements in visual studio like that in QT
http://www.tuxradar.com/files/qt_menq_spacers.jpg
You might be able to use the Margin and Padding properties of any control to that end.
Edit: In response to your comment, I get the impression that your main goal is not to add a certain amount of space between controls (which would be what the Margin and Padding properties are for), but that you want to align controls along certain lines or edges. In Winforms, this is usually done via a combination of panels and the proper use of a control's Anchor and Dock properties.
You can use Anchor property to position controls relative to the dialogs edges.
And you can use a couple of panels to separate controls into different areas.
But I don´t think there is some thing like the spacers you mentioned in the question.

Full-screen window sizing in screen (pixel) units with VS6 C++ GUI editor, MFC?

I am trying to create a full-screen control panel window with many controls: buttons, sliders, list boxes, etc.
I can create a dialog window and add controls to it, but everything is scaled in dialog units. I just want to create a window in the GUI editor that is scaled in pixels, not derived units like dialog units.
I can sort of lay out all the controls in the GUI editor and then resize the window programmatically to full-screen using SetWindowPos, but the dialog window in the GUI editor will not look the same as the final product. I want it to be WYSIWIG in the GUI editor.
This is the front end for a small dedicated instrument control computer running XP. The SDK is written in MFC. I have to add and change controls frequently. The screen is small, 7" # 800 x 600, so of course I am developing the program on a different computer. I don't want the program window to change when I change monitors -- I want it fixed at 800 x 600, and I want the controls to be fixed in size and layout as well.
There must be a way -- this is more basic than the default functionality.
Thanks.
Dialog Units are based on properties of the font used by the dialog. A horizontal dialog unit is equal to 1/4th the average width of the current font.
A vertical dialog unit is equal to 1/8th the average character height of the current font.
I'd recommend using method 2 (MapDialogRect() for a 4 x 8 dialog) to figure out how many DLUs 800x600 corresponds to on your output display then make a reference form equal to that size. You can later use that reference form while you're designing.
p.s.-I'm glad Visual Studio no longer emphasizes dialog units since they were always a pain to deal with.
Thanks. I was able to make a reference form by just resizing the form manually in the GUI editor over and over again until it exactly filled the screen... No kidding that dialog units are a pain. From your response, I guess in the current Visual Studio there is a better way to do this? (This is my first experience with Windows programming).

Aligning Form in Visual Studio 2005

I am trying to add functionality to a form in Visual Studio 2005 that extends the form to the left. However, I am unable to figure out how to change the top and left alignment of he form in the form designer. There has to be a way to change the alignment of a form in the designer, right?
If you mean that you wish to extend the form (in the designer) to the left in order to make space for new controls, I don't believe you can do it - you need to drag out the right side of the frame, then select all the other controls (just drag around them all with the selector tool) and then drag them to the right (you can also move them with right arrow key to ensure they stay at the same Y position).

Drawing a line in Visual Studio .net at design time

The owner of my company wants to be able to draw lines in Visual Studio.net as he did Visual Basic 6.0. So far the only method I have found is a runtime method using system.drawing which of course only work during runtime, and not quite practical for what he wants to do.
Is there any third party control (free or otherwise) that will give him a button at design time to draw lines?
Use the Visual Basic Powerpack (free, from Microsoft, the makers of VB.Net)
The best way to draw a line in design time is to add PictureBox and set its properties as follows:
BackColor - select the color you want
Size - ex: width=1 height=300
The best option is to draw a label and set its properties as follows:
Clear the Text property.
Set the Autosize property to False.
Set BackColor as reqiured.
Set the Enabled property to False (or else it can be moved at run time).
Use Shift + arrows to resize the label, e.g. Shift+↑ to make a thin line and Shift+← to make a small line.

Resources