new bloke having issues again.I have a button on a form which is set to create another button in it's current location, then using a timer that runs
button.top = button.top + 10
for every tick, the design created (aka button creator) button moves down to just under the new button, and in the same alignment. Due to the size of the form I'm working on, once this has been done 3 times, the creator button is now askew, slightly to the right of the added buttons above it, rather than than in the same place, due to the controls now extending past the form size and the scrollbar becoming visible.
I've done some searching around, but so far the answers I have found haven't helped - probably more due to me not understanding correctly - and it's starting to do my head in because it should logically be so simple.
I thought I'd figured out the issue this evening when I realised that it's the previously added buttons which are moving from
location.x = 100
to
location.x = 91
and not the creator button changing it's habits.
Can anyone point out what is probably something so simple that I am overlooking in order to get these aligned?
Thanks in advance.
instead of using the location.x property try using LEFT property of the object...
so when you create the NEW button and set its inital position use the ThisButton.Left = Value to position it....
where ThisButton is the NAME of your button
and Value is the X location numeric value.
Related
I am working on a listview of items and I need to allow user to scroll up/down but I need the bring into view handling to bring the item into view as well as a small part of the next item (in scrollviewer extent). This will indicate to user that there is an item above or below in the list.
I have made a simplified sandbox app to work on this and here are screenshots of what I am trying to do. Arrow indicates scroll direction and the red parens indicate the part I cannot get to show up, meaning the partial amount of the next item.
Please ask if you need anything clarified, I understand this is a complex explanation.
What I have tried:
margin (+/-) on ItemsPresenter/ScrollViewer/ListView
handling ListView.SelectionChanged and using math and various logic to determine direction of scroll and then use ScrollViewer.ChangeView call with calculated vertical offset value.
handling ListView.BringIntoViewRequested and set args.Handled = true and issue new request with various BringIntoViewOptions values, including VerticalOffset, VerticalAlignmentRatio, and new TargetRect with adjusted Y value.
I have read several helpful existing questions here on SO that led me to the BringIntoViewOptions attempt. But nothing so far has worked.
None of these have worked. If I could describe what I want it would be to utilize the existing BringIntoView functionality but bring the item far enough into view that the next item shows a little.
How to open the ContextMenuStrip programmatically at the cursor on right mouse button down/clicked over PictureBox?
I need to open ContextMenuStrip only in some areas of an Image (Schedule) in a PictureBox, so I disconnected the PictureBox.ContextMenuStrip property from the ContextMenuStrip1 and I'm firing it manually. That means I need to provide a point, which appears to be surprisingly challanging.
My question is similar to "How to get location of ContextMenuStrip", but I need to account for both vertical and horizontal scrolling, which it doesn't (unless I messed something).
So when I'm trying something like this (in PictureBoxPlan.MouseDown):
Dim rpt As Point = Me.PointToClient(PictureBoxPlan.Parent.PointToScreen(e.Location))
...it has a fundamental flaw, because the e.Location is in context of Image, regardless how it is scrolled within the PictureBox. I tried to Form.MouseDown event, but it's not fired, when [right] clicked on a PictureBox.
Just for confirmation, I still need the point in PictureBox context to analyze whether the ContextMenuStrip should be shown or not and to lookup associated ID.
I am now trying to use some constants (may not work if windows "font size" is set to other than 100%) together with scroll bars values, which is not optimal at all.
OK, I found what is breaking the logic in the ContextMenuStrip.Show(Point) documentation:
Show(Point)
Positions the `ToolStripDropDown` relative to the specified screen location.
So the ContextMenuStrip, to my surprise, takes the screen coordinates, not the Form ones. I then just removed PointToClient and everything works as a charm, regardless of window position on the screen or scrollbars position of the Image container:
Dim rpt As Point = PictureBoxPlan.PointToScreen(New Point(e.Location.X, e.Location.Y))
No need to take into account PanelPlan.VerticalScroll.Value or PanelPlan.HorizontalScroll.Value.
In the design window, I have my controls formatted one way, but when I run my program, the formatting changes. The window looks larger and the digit button is no longer aligned. I have no clue how to fix this. I am taking an intro level course, so I can't fix this with code. When I wrote my first couple of programs, I didn't have an issue with resizing, but for the last two or three, they never hold their size.
My Program
the above issue please check the anchor tag of each control it should be Top left.
To hold the control position
1 Add panel control to form then dock it to form
2 Add the other
control it will hold the control position as well
I'm trying to test effect animations on shapes in a VBA procedure.
I've already achieved one which is adding some new animations in the MainSequence, defining in which position in the Timeline... but I am not able to create disapearing animations.
I checked in the beginning of the code some already there...and the EffectType seems to return the same value as related appearing animation, so that I sadly believe there's no way of creating disapearing animations in VBA.
Please tell me I am wrong, I have to do the same creations on over 300 slides...
Yes, you are wrong, however documentation to that is... well, I guess you know that already.
Here's the trick. To add a disappearing animation you have to add appearing animation but set it's 'Exit' property to 'msoTrue'
Take a look at this code example:
Private Sub SetAnimation()
Dim effNewEffect As Effect
With ActiveWindow.View.Slide
Set effNewEffect = .TimeLine.MainSequence.AddEffect(.Shapes(.Shapes.Count), msoAnimEffectAppear, trigger:=msoAnimTriggerWithPrevious, Index:=-1)
End With
effNewEffect.Timing.TriggerDelayTime = 1.0
effNewEffect.Exit = msoTrue
End Sub
It will add a Disappear animation to the last Shape in a current slide as the last in the MainSequence with delay 1.0 s to the previous animation.
The solution I found is to use an "Exit" property on the "Effect" object.
The "Exit" property is msoFalse by default.
Can't believe I have the answer to anything but here goes.
Select object to disappear
Go to animations an select fade out (red one)
Open animation pane
go to the click down menu for the object
Select Effect options
Go to timing menu
Click triggers
Click "start effect on click of" and find the object number that matches the one on the animation panel for it.
Job done.
I am designing a VBA UserForm (in Excel, if it is relevant) and I would like some controls to be visually grouped together.. but when I put them in a frame, I am getting some undesired results (part of it has to do with the RefEdit control which seems to be particularly unhappy inside a frame).
Is there a way to draw a border around a group of controls on a form without putting them inside a Frame?
Use a label with the caption deleted and the border style set to fmBorderStyleSingle. It may appear on top of your other controls, so right click on it and select "send backwards" until it's behind your other controls.
The best way to do this would be to create the shape over where you need it to be. Drag highlight everything that you want on top of it, then right click and brink it all forwards. Then when you drag your shape back over the top it will in fact be underneath everthing else.
Hope that helps.
This worked for me and I was at first having the same issue where I had to choose to "Send Backward" up to 30 times per label in some cases. I found that hitting the Ctrl-K sends it to the back of all controls with one time hitting these keys.