📄 defaultvb.aspx.vb
字号:
Imports System
Imports System.Collections
Imports System.ComponentModel
Imports System.Data
Imports System.Drawing
Imports System.Web
Imports System.Web.SessionState
Imports System.Web.UI
Imports System.Web.UI.WebControls
Imports System.Web.UI.HtmlControls
Imports Telerik.QuickStart
Imports Telerik.WebControls
Namespace Telerik.ChartExamplesVB.Configurator.Elements.XAxis
'/ <summary>
'/ Summary description for _Default.
'/ </summary>
Public Class DefaultVB
Inherits XhtmlPage
Protected RadChart1 As Telerik.WebControls.RadChart
Protected cbAutoScale As System.Web.UI.WebControls.CheckBox
Protected Label1 As System.Web.UI.WebControls.Label
Protected Label2 As System.Web.UI.WebControls.Label
Protected Label3 As System.Web.UI.WebControls.Label
Protected cbShowMarks As System.Web.UI.WebControls.CheckBox
Protected cbShowItemLabels As System.Web.UI.WebControls.CheckBox
Protected Label4 As System.Web.UI.WebControls.Label
Protected Label6 As System.Web.UI.WebControls.Label
Protected Label7 As System.Web.UI.WebControls.Label
Protected Label8 As System.Web.UI.WebControls.Label
Protected Label9 As System.Web.UI.WebControls.Label
Protected txtBoxSeriesItemsCount As System.Web.UI.WebControls.TextBox
Protected ddlSeriesType As System.Web.UI.WebControls.DropDownList
Protected txtBoxItemsCount As System.Web.UI.WebControls.TextBox
Protected ddlAxisStyle As System.Web.UI.WebControls.DropDownList
Protected txtBoxAxisLabel As System.Web.UI.WebControls.TextBox
Protected txtBoxMarkLength As System.Web.UI.WebControls.TextBox
Protected txtBoxSpaceToItemLabel As System.Web.UI.WebControls.TextBox
Protected txtBoxSpaceToAxisLabel As System.Web.UI.WebControls.TextBox
Protected Label5 As System.Web.UI.WebControls.Label
Protected ddlHorAlignment As System.Web.UI.WebControls.DropDownList
Protected Label10 As System.Web.UI.WebControls.Label
Protected txtBoxRotationAngle As System.Web.UI.WebControls.TextBox
Protected ddlValueFormat As System.Web.UI.WebControls.DropDownList
Protected txtBoxCustomFormat As System.Web.UI.WebControls.TextBox
Protected lblIncorrectSettings As System.Web.UI.WebControls.Label
Protected WithEvents Button1 As System.Web.UI.WebControls.Button
Private Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles MyBase.Load
If Not Page.IsPostBack Then
InitControls()
SetControlValues()
End If
End Sub 'Page_Load
Private Sub InitControls()
InitControl(ddlAxisStyle, GetType(ChartAxisLayoutStyle))
InitControl(ddlSeriesType, GetType(ChartSeriesType))
InitControl(ddlHorAlignment, GetType(ChartHAlignment))
InitControl(ddlValueFormat, GetType(ChartValueFormat))
End Sub 'InitControls
Private Sub SetControlValues()
txtBoxSeriesItemsCount.Text = RadChart1.ChartSeriesCollection(0).Items.Count.ToString()
txtBoxItemsCount.Text = RadChart1.XAxis.Items.Count.ToString()
txtBoxAxisLabel.Text = RadChart1.XAxis.Label.Text
txtBoxAxisLabel.Text = RadChart1.XAxis.Label.Text
txtBoxSpaceToAxisLabel.Text = RadChart1.XAxis.SpaceToLabel.ToString()
txtBoxSpaceToItemLabel.Text = RadChart1.XAxis.SpaceToItem.ToString()
txtBoxMarkLength.Text = RadChart1.XAxis.MarkLength.ToString()
SetControlValue(ddlSeriesType, RadChart1.ChartSeriesCollection(0).Type.ToString())
SetControlValue(ddlAxisStyle, RadChart1.XAxis.LayoutStyle.ToString())
SetControlValue(ddlHorAlignment, RadChart1.XAxis.Label.HAlignment.ToString())
cbAutoScale.Checked = RadChart1.XAxis.AutoScale
cbShowMarks.Checked = RadChart1.XAxis.ShowMarks
cbShowItemLabels.Checked = RadChart1.XAxis.ShowLabels
End Sub 'SetControlValues
Private Sub InitControl(ByVal ddList As DropDownList, ByVal type As Type)
Dim valueNames As String() = [Enum].GetNames(type)
ddList.Items.Clear()
Dim s As String
For Each s In valueNames
ddList.Items.Add(s)
Next s
End Sub 'InitControl
Private Sub SetControlValue(ByVal ddList As DropDownList, ByVal val As String)
ddList.SelectedIndex = ddList.Items.IndexOf(ddList.Items.FindByValue(val))
End Sub 'SetControlValue
#Region "Web Form Designer generated code"
Protected Overrides Sub OnInit(ByVal e As EventArgs)
'
' CODEGEN: This call is required by the ASP.NET Web Form Designer.
'
InitializeComponent()
MyBase.OnInit(e)
End Sub 'OnInit
'/ Required method for Designer support - do not modify
'/ the contents of this method with the code editor.
'/ </summary>
Private Sub InitializeComponent()
End Sub 'InitializeComponent
#End Region
Private Sub Button1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button1.Click
Try
ApplySettings()
lblIncorrectSettings.Visible = False
Catch
lblIncorrectSettings.Visible = True
End Try
End Sub 'Button1_Click
Private Sub ApplySettings()
SetSeriesItems()
RadChart1.ChartSeriesCollection(0).Type = CType([Enum].Parse(GetType(ChartSeriesType), ddlSeriesType.SelectedItem.Value), ChartSeriesType)
RadChart1.ChartSeriesCollection(1).Type = CType([Enum].Parse(GetType(ChartSeriesType), ddlSeriesType.SelectedItem.Value), ChartSeriesType)
SetAxisItems()
RadChart1.XAxis.AutoScale = cbAutoScale.Checked
RadChart1.XAxis.LayoutStyle = CType([Enum].Parse(GetType(ChartAxisLayoutStyle), ddlAxisStyle.SelectedItem.Value), ChartAxisLayoutStyle)
RadChart1.XAxis.Label.Text = txtBoxAxisLabel.Text
RadChart1.XAxis.ShowMarks = cbShowMarks.Checked
RadChart1.XAxis.ShowLabels = cbShowItemLabels.Checked
RadChart1.XAxis.MarkLength = Integer.Parse(txtBoxMarkLength.Text)
RadChart1.XAxis.SpaceToLabel = Integer.Parse(txtBoxSpaceToAxisLabel.Text)
RadChart1.XAxis.SpaceToItem = Integer.Parse(txtBoxSpaceToItemLabel.Text)
RadChart1.XAxis.Label.HAlignment = CType([Enum].Parse(GetType(ChartHAlignment), ddlHorAlignment.SelectedItem.Value), ChartHAlignment)
RadChart1.XAxis.LabelRotationAngle = Double.Parse(txtBoxRotationAngle.Text)
RadChart1.XAxis.ValueFormat = CType([Enum].Parse(GetType(ChartValueFormat), ddlValueFormat.SelectedItem.Value), ChartValueFormat)
RadChart1.XAxis.CustomFormat = txtBoxCustomFormat.Text
End Sub 'ApplySettings
Private Sub SetSeriesItems()
Dim itemsCount As Integer = Integer.Parse(txtBoxSeriesItemsCount.Text)
Dim dItems As Integer = itemsCount - RadChart1.ChartSeriesCollection(0).Items.Count
Dim r As New Random()
If dItems > 0 Then
While dItems > 0
RadChart1.ChartSeriesCollection(0).AddItem(r.Next(0, 100))
RadChart1.ChartSeriesCollection(1).AddItem(r.Next(0, 100))
dItems -= 1
End While
Else
While dItems < 0
RadChart1.ChartSeriesCollection(0).Items.RemoveAt((RadChart1.ChartSeriesCollection(0).Items.Count - 1))
RadChart1.ChartSeriesCollection(1).Items.RemoveAt((RadChart1.ChartSeriesCollection(1).Items.Count - 1))
dItems += 1
End While
End If
End Sub 'SetSeriesItems
Private Sub SetAxisItems()
Dim axisItemsCount As Integer = Integer.Parse(txtBoxItemsCount.Text)
Dim dItems As Integer = axisItemsCount - RadChart1.XAxis.Items.Count
If dItems > 0 Then
Dim itemNumber As Integer = RadChart1.XAxis.Items.Count
While dItems > 0
itemNumber += 1
RadChart1.XAxis.Items.Add(New ChartAxisItem(itemNumber.ToString(), Color.Empty))
dItems -= 1
End While
Else
While dItems < 0
RadChart1.XAxis.Items.RemoveAt((RadChart1.XAxis.Items.Count - 1))
dItems += 1
End While
End If
End Sub 'SetAxisItems
End Class 'DefaultCS
End Namespace 'Telerik.ChartExamplesCS.XAxis
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -