如何使用我的列表框的内容来填充直方图 [英] How to use the contents of my Listbox to fill a histogram

查看:70
本文介绍了如何使用我的列表框的内容来填充直方图的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

您好,

我正在试图弄清楚如何使用我在Form1上从listbox输入的数据来填充Form2上的histogram。



我终于想出了如何将数据导入列表框。请参阅下面的代码:



公共类Form1

朋友myArray(5)As StringAlignment

朋友索引为整数= 0



Private Sub Button1_Click(发送者为对象,e为EventArgs)处理Button1.Click

尝试

myArray(index)= Me.TextBox1.Text

index + = 1

Me.ListBox1.Items.Add(TextBox1.Text)

Me.TextBox1.Clear()

Me.TextBox1.Focus()

Catch ex As IndexOutOfRangeException

MsgBox(你有太多了这个数组的项目!)

结束尝试





结束子



Private Sub Button2_Click(发送者为对象,e为EventArgs)处理Button2.Click

Form2.Show()

End Sub

结束班级





所以这里我已经想出了另外一个我知道如何创建直方图,但我想使用我在列表框中输入的条目数作为'x轴',将实际数据(数字)作为'y轴'。我怎么能告诉直方图从列表框中抓取'x'和'y'?



如果我使用数组,是否有关于如何使用我可以输入多个条目?如果我拿出(5)它不起作用。是否需要一些号码?





谢谢。

解决方案

< blockquote>你没有告诉'Form2'任何其他信息,除了它应该在屏幕上可见。你必须在调用`Form2.Show()`和它实际出现在屏幕上的点之间进行某种初始化过程。



拿一个看看` Form.Load `事件。您应该采取某种操作来处理此事件,以通知直方图的XY信息。


Hello,
I am trying to figure out how to use the data that I inputted from my "listbox" on Form1 to fill the "histogram" on Form2.

I finally figured out how to get the data into the listbox. See code below:

Public Class Form1
Friend myArray(5) As StringAlignment
Friend index As Integer = 0

Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
Try
myArray(index) = Me.TextBox1.Text
index += 1
Me.ListBox1.Items.Add(TextBox1.Text)
Me.TextBox1.Clear()
Me.TextBox1.Focus()
Catch ex As IndexOutOfRangeException
MsgBox("You have too many items for this array!")
End Try


End Sub

Private Sub Button2_Click(sender As Object, e As EventArgs) Handles Button2.Click
Form2.Show()
End Sub
End Class


So here I have figured out to add another form and I know how to create the histogram, but I want to use the number of entries that I enter into the listbox as the 'x-axis' and the actual data (numbers) as the 'y-axis'. How can I tell the histogram to grab the 'x' & 'y' from the listbox?

Also if I am using an array, is there a cap on how many entries I can type in? If I take the (5) out it does not work. Does there have to be some number?


Thank you.

You are not telling 'Form2' any additional information other then it should be visible on screen. You have to do some sort of initialization process between the time that you call `Form2.Show()` and the point when it actually appear on screen.

Take a look at the `
Form.Load` event for Form2. You should do some kind of action handling this event to notify your histogram of the XY information.


这篇关于如何使用我的列表框的内容来填充直方图的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆