Scroll FlowPanel scrollbar with a Trackbar - vb.net

I have a FlowLayoutPanel1 in my form with a bunch of buttons inside it. I wanted to change the way its scroll bar looked so I added a TrackBar1 hoping to make it look better. I can't figure out how to do it.
I tried:
Panel1.AutoScroll.value = TrackBar1.Value
But it gives the error:
'value' is not a member of Boolean
What have I done wrong in this code?

Your code is wrong. Change it to
Panel1.HorizontalScroll.Value = TrackBar1.Value
Here, Panel1.AutoScroll only tells you if it's True or False.

I got it guys. I should've put .VerticalScroll.Value instead of AutoScroll.Value.
Panel1.VerticalScroll.Value = TrackBar1.Value
This worked.

As others have already mentioned, Panel1.AutoScroll is a boolean. You need to use HorizontalScroll.Value or VerticalScroll.Value whichever matches your requirement.

Related

VB.NET Placeholder in MaskedTextBox

I have a maskedtextbox with the following mask : 999999. I would like to add something like a placeholder in HTML to help the end user to know the mask of my maskedtextbox.
I think that i can create a specific mask when the form load and set the text property to "YYYYMM" (the placeholder that i need) and when the user enter in the control, reset the text and change the mask to 999999. However, i think there are better solutions.
I find some people talking about watermark control, but i would like to find something easier to use.
Any help will be appreciate. Thanks
Use a DateTimePicker, that would be the easiest way, as suggested.
However, to do as the question asked...
On Form_Load, set MaskedTextBox1.Text = "YYYYMM"
Then, to get the effect of changing the mask to 999999 when the control is in focus, use the MaskedTextBox1_GotFocus method and use MaskedTextBox1.Text = "999999".
As suggested by tinstaafl in comments, i used a DateTimePicker instead of a MaskedTextBox.
I changed its properties :
CustomFormat = yyyMM
Format = Custom
ShowUpDown = True
This way, i have something similar to a textBox and i can select only the year or only the month and increase it with the up and down buttons.

Reset Datagridview SelectionBackColor

In my code I have need to turn the SelectionBackColor to red to notify the user of something. When that has been rectified I wish to set it again back to its default (Blue with white text). I use color.empty but this seams to not work correctly. It resets the color BUT subsequent repeat changes to SelectionBackColor are not implemented.
I use this to change it Me.DataGridView1.DefaultCellStyle.SelectionBackColor = Color.Red
and this to reset Me.DataGridView1.DefaultCellStyle.SelectionBackColor = Color.Empty
But as I said subsequent attempts to change the color fails, even when done on the same cell that worked the first time. As I said above it's as if Im not resenting correctly. OR is it that this can only be changed once? Unlikely though
EDIT:
I tried to change the color to green instead of empty and that has worked correctly, several times over changing the color from red to green as expected. So it is definitely an issue with the color.empty (trying to reset it to default) and not code or logic anywhere else.
Thanks for any thoughts you may have
Edit2: Is there a way to capture the default style and then recall it? So instead changing to green I change to the saved default style?
the answer I found by trial and error to reset the SelectionBackColor is to first capture it and then use it when resetting.
Dim GridBackcolor As Object
GridBackcolor = Me.DataGridView1.DefaultCellStyle.SelectionBackColor
'set another color
Me.DataGridView1.DefaultCellStyle.SelectionBackColor = Color.Red
'reset
Me.DataGridView1.DefaultCellStyle.SelectionBackColor = GridBackcolor
in case it helps anyone.
for me, the solution was to set:
.DefaultCellStyle.SelectionBackColor
AND
.DefaultCellStyle.SelectionForeColor
switch to custom colors and back worked allready....
BUT
the 2. switch dosent changed the selection color. also not the background and forecolor...
perhaps the datagridview "think" one of them (selectionforecolor, selectionbackcolor, background, forecolor) could be the "same" color and has a problem with switching them ... ?
cheers :-)

how to offset form in vb

the question is rather simple, but what I am working on is not..
this is a marker from a control called GMaps.NET
the next picture is a form, that follows the marker when I drag the map, something like the InfoWindow on google maps API.
only problem is that, it covers the marker, and I can't offset it no matter how hard I think.
this is my current code..
Private Sub map_OnMapDrag() Handles map.OnMapDrag
Form2.Show()
Form2.Location = camera1.LocalPosition
End Sub
please list some ways on how I can offset it so we can see the marker.. thanks!
Reminder : you can't directly use camera1.LocalPosition's Point because its coordinates are inside the map. whilst Form2.Location is on the form. though the same value, they are worlds apart :)
so give different options that I can try TIA
Try out Form2.Location.Offset(dx, dy)

VB.net prevent a tooltip from showing

In my program i use tooltips to help new users have some idea of what the icon buttons do. I also have an option to turn tooltips off.
There appears to be a tooltip.hide method, but i don't quite understand how to use it.
So how do i get a tooltip to not display if a boolean value is set to false.
Using the Active property should meet your needs, it's more simple than using the Hide and Show methods.
'Hide ToolTip
ToolTip.Active = False
'Show ToolTip
ToolTip.Active = True
tooltip.Hide() is used to hide the ToolTip while is being shown.
If you want the tooltips now showing you can put a condition when calling to the point that shows them:
If Not chkBoxNoToolTips.Checked Then
tooltip1.Show()
End If
Or you can remove the tooltips from its controls if they are automatically set:
tooltip1.SetToolTip(label1, "")
Call SetToolTip and pass through your control and an empty string, you could probably pass through a null reference also but I haven't tried it myself.
This should remove the tooltip for you
ToolTip1.SetToolTip(txtBox1, "")
Hope it helps

DataGridView and Combobox Column?

when DataGridView has a combobox column, how can I get the text it displays as oppose to the value it represents? When I do DGV.Item("cbo",i).Value I get the value but it won't take DGV.Item("cbo",i).Text. I trying Ctype(DGV.Item("cbo",i),ComboBox).Text and this does not work either.
Try
DGV.item("cbo",i).DisplayMember
Umm are you talking about Win Forms?
If so, Value is the property you want, and is what is to be displayed on the screen and held behind the scenes.
If you want something different not shown to the user, I've often used the property Tag for that.
I found this, and the answers didn't work for me. In case someone else finds this, here is what I did.
dgv.rows(i).Cells(cboname.index).EditedFormattedValue
Hope if someone finds this through Google it will help them.
Dim dgvcmbcell As DataGridViewComboBoxCell = DgvItemsUnits.Item("UNIT_SER", 0)
Dim SelectedText As String = dgvcmbcell.EditedFormattedValue.ToString()