MS Chart Tooltips appearing on random points and not in order - vb.net

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?

Related

Align a text frame when creating a ppt from access vba

I'm trying to align a text frame when creating a ppt from access. Alignment control is available from excel vba but I'm struggling to find this in access.
Here is an example of the creation of a textbox in powerpoint from access vba. I have control of the font size and such but I cannot locate the alignment for the textbox.
' Program data
Dim tb_ProgramData As Shape
Set tb_ProgramData = pptCurrentSlide.Shapes.AddTextbox(msoTextOrientationHorizontal, Left:=68.399, Top:=51.12, Width:=187.2, Height:=18.72)
tb_ProgramData.TextFrame.TextRange.Text = rs.Fields(27) + " Program: " + rs.Fields(29)
tb_ProgramData.TextFrame.TextRange.Font.Size = 9
tb_ProgramData.TextFrame.TextRange.Font.Bold = msoTrue
The only thing close is a paragraph alignment but it has no effect...
tb_Title.TextFrame.TextRange.ParagraphFormat.Alignment = ppAlignCenter
Any help would be appreciated... regards,
Good grief.. I found it under the text effects.
tb_SystemClass.TextEffect.Alignment = msoTextEffectAlignmentRight
and if you wish to select the textbox from the list of shapes then...
pptCurrentSlide.Shapes.Range("tb_SystemClass").TextEffect.Alignment = msoTextEffectAlignmentRight

Visual Basic 2010 Location Property is acting strange

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.

Setting a Custom Paper Size in Printer from VB.Net 2010

I want to print on the custom paper size 180 mm * 90 mm , i am using vb.net 2010 and print document, i tried to change the paper size use this code
document.DefaultPageSettings.PaperSize = New PaperSize("custom", TextBox21.Text, TextBox22.Text)
its working fine in print preview but when i am printing its printing on paper size " letter " , i tried also ComboPaperSize and PageSetupDialog using this code , i chose " custom_paper1_size " in compoPaerSize and i used this code also for check the paper size in pagesetupdialog, the paper size changed in pagesetupdialog to " letter " height = 1100 , width = 850
THis the combobox for paper size
comboPaperSize.SelectedIndex = -1
`enter code here` comboPaperSize.DisplayMember = "PaperName"
Dim pkSize As PaperSize
For i = 0 To PrintDocument1.PrinterSettings.PaperSizes.Count - 1
pkSize = PrintDocument1.PrinterSettings.PaperSizes.Item(i)
comboPaperSize.Items.Add(pkSize)
Next
' Create a PaperSize and specify the custom paper size through the constructor and add to combobox.
Dim pkCustomSize1 As New PaperSize("Custom_Paper1_Size", TextBox21.Text, TextBox22.Text)
comboPaperSize.Items.Add(pkCustomSize1)
This is for the page setup dialog
PageSetupDialog1.PageSettings = _
New System.Drawing.Printing.PageSettings
PageSetupDialog1.PageSettings.PaperSize = comboPaperSize.SelectedItem
PageSetupDialog1.PageSettings.Landscape = True
' Initialize dialog's PrinterSettings property to hold user
' set printer settings.
PageSetupDialog1.PrinterSettings = _
New System.Drawing.Printing.PrinterSettings
'Do not show the network in the printer dialog.
PageSetupDialog1.ShowNetwork = False
'Show the dialog storing the result.
Dim result As DialogResult = PageSetupDialog1.ShowDialog()
I lost one week now searching for solve this problem .
can anyone please tell me how to print landscope on paper custom paper size without page margins .
Thanks

Table layout panel inc#

I have to create dynamic table layout panel with some controls with auto sized rows and and fixed columns size.
My problem is that i want to show whole checkbox text .
Any help
My code is
Dim textBox2 As New CheckBox()
textBox2.Text = "You forgot to add the ColumnStyles. Do this on a sample form first with the designer. Click the Show All Files icon in the Solution Explorer window. Open the node next to the form and double-click the Designer.vb file. "
textBox2.AutoSize = True
textBox2.Dock = DockStyle.Top
'' textBox2.Size = New Point(200, 90)
Dim lbl1 As New Label()
lbl1.Location = New Point(10, 10)
lbl1.Text = "Yoer.vb"
lbl1.AutoSize = True
lbl1.Location = New Point(120, 50)
lbl1.Dock = DockStyle.Top
'' dynamicTableLayoutPanel.Padding = New Padding(2, 17, 4, 5)
dynamicTableLayoutPanel.Controls.Add(lbl1, 0, 0)
dynamicTableLayoutPanel.Controls.Add(textBox2, 1, 0)
Me.dynamicTableLayoutPanel.SetColumnSpan(textBox2, 5)
If you mean you want the table to size to the controls within it, then:
dynamicTableLayoutPanel.AutoSize = True
I know this is old, but I stumbled across it and figured I'd throw my 2 cents in in case someone else comes along.
Note: I'm using Visual Studio 2015 with .NET 4.6. Functionality may differ between versions.
The problem is that the really long text is not word-wrapping to fit within the table or form. Instead, it is set to Dock = DockStyle.Top. This will cause it to make a single line that continues on and gets clipped, similar to a single-line textbox.
If you want it to automatically word wrap, you'll need to use Dock = DockStyle.Fill. Now, this doesn't completely resolve the problem if your row or table isn't large enough to display the text. Since all of the rows are set to AutoSize, it will only do the bare minimum to fit the control vertically. It doesn't care if text gets clipped off. The end result, using your example code against a 6-column, 10-row table, is this:
Since there isn't a word wrap property, you'll need to manually fit it. Now, to do this, you'll need to change the row to be Absolute instead of AutoSize. To figure out how big to make it, you can pretty much rely on PreferredSize. This reveals a much wider Width than the existing regular Width. From that, we can determine how many lines it would take if we wrap it.
This is what my code ended up looking like:
Dim h As Single = 0
Dim chk As New CheckBox()
chk.Text = "You forgot to add the ColumnStyles. Do this on a sample form first with the designer. Click the Show All Files icon in the Solution Explorer window. Open the node next to the form and double-click the Designer.vb file. "
chk.AutoSize = True
chk.Dock = DockStyle.Fill
Dim lbl1 As New Label()
lbl1.Text = "Yoer.vb"
lbl1.AutoSize = True
lbl1.Dock = DockStyle.Top
dynamicTableLayoutPanel.Controls.Add(lbl1, 0, 0)
dynamicTableLayoutPanel.Controls.Add(chk, 1, 0)
dynamicTableLayoutPanel.SetColumnSpan(chk, 5)
' Find the preferred width, divide by actual, and round up.
' This will be how many lines it should take.
h = Math.Ceiling(chk.PreferredSize.Width / chk.Width)
' Multiply the number of lines by the current height.
h = (h * chk.PreferredSize.Height)
' Absolute size the parent row to match this new height.
dynamicTableLayoutPanel.RowStyles.Item(0) = New RowStyle(SizeType.Absolute, h)
The changes included delaring a height variable, renaming the CheckBox variable, setting its Dock to Fill, removing the Location from lbl1, and adding in size calculation. The output:
This isn't perfect since the height includes the checkbox itself, and the checkbox takes up padding, so there can be too much or too little height calculated. There are other calculations that may need to be considered. But, this is a starting point.

Excel VBA: Positioning and Alignment of Shapes

I am trying to make a printable report from excel sheet with some shapes such as charts and pictures. I am able to put the charts on the sheet using the below code:
oSheetReport.Range("A51").Select()
Dim oChart1 As Excel.Shape
oChart1 = oSheetReport.Shapes.AddChart()
oChart1.Chart.ChartType = Excel.XlChartType.xlLine
oChart1.Chart.SetSourceData(Source:=oSheet.UsedRange)
oSheetReport.Range("A70").Select()
oChart1 = oSheetReport.Shapes.AddChart()
oChart1.Chart.ChartType = Excel.XlChartType.xlColumnStacked
oChart1.Chart.SetSourceData(Source:=oSheet.UsedRange)
oSheetReport.Range("A100").Select()
oChart1 = oSheetReport.Shapes.AddChart()
oChart1.Chart.ChartType = Excel.XlChartType.xlColumnStacked100
oChart1.Chart.SetSourceData(Source:=oSheet.UsedRange)
But positioning and alignment is failing which is making my reports look ugly. Any better way of achieving this?
To add, position and align in one step you can use the following:
Set oChart1 = ActiveSheet.ChartObjects.Add _
(Left:=250, Width:=375, Top:=75, Height:=225)
Left is the left alignment and Top is the top alignment. Width and Height - well, you can figure that out!
More info at http://peltiertech.com/Excel/ChartsHowTo/QuickChartVBA.html