如何在.net 3.5跟踪栏中标记最小,最大,中心刻度?

| 我需要在应用程序中设置电压。我习惯在Labview中使用滑块,并想使用C#程序复制滑块。 我已经弄清楚轨迹栏只做整数值,所以不是使用双精度值将范围从-5改为5,而是让轨迹栏从-50变为+50,且每10个刻度线获得0.1v分辨率的步骤。 如何标记轨迹栏的最小值和最大值? | ----- | ----- | ----- | ----- | ----- | ----- | ----- | ----- |- ---- | ----- | -5.0的-5.0的-0.0的-5.0 我正在Visual Studio中将C#与.net 3.5一起使用。     
已邀请:
最简单的方法是使用轨迹栏的高度/宽度/顶部/左侧和标签的组合添加到2-3个标签,您应该能够相对轻松地放置它们? 编辑:而且,似乎这篇文章显示了一个自定义实现,其需求与您描述的相同?     
TrackBar缩放图像链接 我要做的是修改图表,并使用其X轴比例作为TrackBar的比例(请参阅图像链接[本来可以嵌入图像,但无法使用])。图像的上半部分是滑块,下半部分是常规图表对象,其属性已更改,因此唯一可见的是其X轴。 这是TrackBar和Chart的VS2010表单设计器代码。本示例将为您提供0到100的比例,可以轻松调整其大小以使其与跟踪栏对齐。您甚至可以将两个控件放在一个面板中,以便可以轻松地将它们调整为一个(代码是VB而不是C#):
        Dim ChartArea2 As System.Windows.Forms.DataVisualization.Charting.ChartArea = New System.Windows.Forms.DataVisualization.Charting.ChartArea()
    Dim Legend2 As System.Windows.Forms.DataVisualization.Charting.Legend = New System.Windows.Forms.DataVisualization.Charting.Legend()
    Dim Series2 As System.Windows.Forms.DataVisualization.Charting.Series = New System.Windows.Forms.DataVisualization.Charting.Series()
    Dim DataPoint2 As System.Windows.Forms.DataVisualization.Charting.DataPoint = New System.Windows.Forms.DataVisualization.Charting.DataPoint(0.0R, 0.0R)
    Me.chart_slider = New System.Windows.Forms.DataVisualization.Charting.Chart()
    Me.TrackBar1 = New System.Windows.Forms.TrackBar()
    CType(Me.chart_slider, System.ComponentModel.ISupportInitialize).BeginInit()
    CType(Me.TrackBar1, System.ComponentModel.ISupportInitialize).BeginInit()
    Me.SuspendLayout()
    \'
    \'chart_slider
    \'
    Me.chart_slider.Anchor = CType((((System.Windows.Forms.AnchorStyles.Top Or System.Windows.Forms.AnchorStyles.Bottom) _
        Or System.Windows.Forms.AnchorStyles.Left) _
        Or System.Windows.Forms.AnchorStyles.Right), System.Windows.Forms.AnchorStyles)
    Me.chart_slider.BackColor = System.Drawing.Color.Transparent
    ChartArea2.AxisX.LabelAutoFitMaxFontSize = 8
    ChartArea2.AxisX.LabelAutoFitMinFontSize = 8
    ChartArea2.AxisX.LineColor = System.Drawing.Color.Transparent
    ChartArea2.AxisX.MajorGrid.Enabled = False
    ChartArea2.AxisX.Maximum = 100.0R
    ChartArea2.AxisX.Minimum = 0.0R
    ChartArea2.AxisY.Interval = 1.0R
    ChartArea2.AxisY.LineWidth = 0
    ChartArea2.AxisY.MajorGrid.Enabled = False
    ChartArea2.AxisY.MajorTickMark.Enabled = False
    ChartArea2.AxisY.Maximum = 0.0R
    ChartArea2.AxisY.Minimum = 0.0R
    ChartArea2.AxisY.TitleForeColor = System.Drawing.Color.Transparent
    ChartArea2.BackColor = System.Drawing.Color.Transparent
    ChartArea2.InnerPlotPosition.Auto = False
    ChartArea2.InnerPlotPosition.Height = 5.0!
    ChartArea2.InnerPlotPosition.Width = 100.0!
    ChartArea2.Name = \"ChartArea1\"
    Me.chart_slider.ChartAreas.Add(ChartArea2)
    Legend2.Enabled = False
    Legend2.Name = \"Legend1\"
    Me.chart_slider.Legends.Add(Legend2)
    Me.chart_slider.Location = New System.Drawing.Point(186, 426)
    Me.chart_slider.Name = \"chart_slider\"
    Series2.ChartArea = \"ChartArea1\"
    Series2.Legend = \"Legend1\"
    Series2.Name = \"Series1\"
    Series2.Points.Add(DataPoint2)
    Me.chart_slider.Series.Add(Series2)
    Me.chart_slider.Size = New System.Drawing.Size(441, 31)
    Me.chart_slider.TabIndex = 160
    Me.chart_slider.Text = \"Chart1\"
    \'
    \'TrackBar1
    \'
    Me.TrackBar1.Anchor = CType((((System.Windows.Forms.AnchorStyles.Top Or System.Windows.Forms.AnchorStyles.Bottom) _
        Or System.Windows.Forms.AnchorStyles.Left) _
        Or System.Windows.Forms.AnchorStyles.Right), System.Windows.Forms.AnchorStyles)
    Me.TrackBar1.Location = New System.Drawing.Point(191, 398)
    Me.TrackBar1.Margin = New System.Windows.Forms.Padding(3, 3, 3, 0)
    Me.TrackBar1.Name = \"TrackBar1\"
    Me.TrackBar1.RightToLeftLayout = True
    Me.TrackBar1.Size = New System.Drawing.Size(423, 45)
    Me.TrackBar1.TabIndex = 1
    \'
    \'Form1
    \'
    Me.AutoScaleDimensions = New System.Drawing.SizeF(6.0!, 13.0!)
    Me.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font
    Me.ClientSize = New System.Drawing.Size(690, 498)
    Me.Controls.Add(Me.TrackBar1)
    Me.Controls.Add(Me.chart_slider)
    Me.Name = \"Form1\"
    Me.Text = \"Form1\"
    CType(Me.chart_slider, System.ComponentModel.ISupportInitialize).EndInit()
    CType(Me.TrackBar1, System.ComponentModel.ISupportInitialize).EndInit()
    Me.ResumeLayout(False)
    Me.PerformLayout()
    

要回复问题请先登录注册