I'm a bit new at programming, so apologies if this is a noob question.
I'm trying to place a button in a form, but for some reason, the button's Location Property in the form doesn't match its actual location. I tested this by making the button's text show its Location Property (in this case, "X = 10, Y = 10"), and putting this code for its click event:
btnTest.Text = "X = " & btnTest.Location.X & ", Y = " & btnTest.Location.Y
For some reason, the text now becomes "X = 8, Y = 8" The button also moves to match this new location. I don't understand why this is happening.
Related
I am working on MS charts with Vb.net to create a Radar chart. For each point I am adding a tooltip on the radar chart.
The same thing works when the chart type is line:
With pnt
If val.Base = 0 Then
yValue = Double.NaN
Else
yValue = val.Percent
.Font = New Font("Calibri", 8.25)
End If
.SetValueXY(xValue, yValue)
If val.Base > 0 Then
.MarkerSize = 5
.MarkerColor = cht.Series(bs).Color
.MarkerBorderColor = cht.Series(bs).Color
.MarkerBorderWidth = 2
.MarkerStyle = MarkerStyle.Circle
.Label = Convert.ToString(.YValues(0))
.ToolTip = Convert.ToString(bs & Chr(10) & se.Measure & " : " & .YValues(0) & "%") & ", Base:" & val.Base
End If
cht.Series(bs).Points.Add(pnt)
End With
However for Radar chart, either there will be no tooltip or it will appear at a random incorrect point. Meaning the first points tooltip will come up near third or fourth on the radar. I edited the output image after trying to hide the markeres, using .MarkerStyle = MarkerStyle.None -
The result is still the same.
Note - These charts are generated on the runtime and added to a div control of the page. I checked using the same chart with the radar chart created in my .aspx file - and that seems to be working fine!
Edit --
I found the main reason behind this issue! I had to adjust the charts, using style="width: 100%;" to fit on the div they are created in. I tried removing the CSS of width and the tooltip align correctly!
Is there a way to keep the CSS (otherwise the charts move out of their containers!) and adjust the tooltip to the CSS?
I'm trying to add a label to a point in VB.Net using the Chart control. Here's my code:
chartMain.Series(1).Points.AddXY(x, y)
chartMain.Series(1).Points(chartMain.Series(1).Points.Count - 1).Label = Math.Round(x, 2) & "nm, " & Math.Round(y, 2) & "%"
However no labels are being displayed. In another program I do this exact same thing and it works perfectly. Is there something I'm missing or may have inadvertently disabled elsewhere?
Try:
ChartMain.Series(1).Points.AddXY(Math.Round(x, 2) & "nm, " & Math.Round(y, 2) & "%", y)
Fixed -
Data point type of "Fast Point" will not display labels, it seems. Changing to just "Point" worked.
I am trying to change the button color on my form in VB.net to red upon click. I have used the code below but I keep getting errors.
Button1.BackColor = Color.Gold
This gets me two errors. The first is " 'BackColor' is not a member of 'System.Windows.Controls.Button' " and the second error is " 'Gold' is not a member of 'System.Windows.Media.Color' " Can someone please point me in the right direction.
This should work:
Button1.Background = System.Windows.Media.Brushes.Gold
Windows forms .net 4.0 vb application. This is a small trivial thing but I was trying to just change the color of one word in label.text. But its not happening and I have a strong feeling that to make it happen is going to be more extensive than its worth... A snippet of what I am trying to use is below... Am I just missing a key detail or is this honestly more of a burden than its worth..
Dim _changeLabel1 As String = " Note Fields Marked in "
Dim _changeLabel2 As String = " are Required"
Dim _attrib As New Label
With _attrib
.ForeColor = Color.Red
.Text = "RED"
End With
_notificationLabel1.Text = _changeLabel1 + " " + _attrib.Text + " " + _changeLabel2
Winform labels don't support this functionality, unfortunately.
You could use multiple labels instead, with one that's red for your RED text.
Here's a related question on the matter.
How can i change color of just specific part of the label.text in visual basic 2010 express?
Dim b As Integer = 34
label.Text = "You have " & b.ToString & " new items"
for example, i just want to change color of the "b" here.
or do i need to create a new label ?
Thanks
Assuming this is Windows Forms: you need to create a new label.
If it's WPF, you can do it by using a TextBlock with Run elements inside it, and setting the foreground of one of the Run elements.