-
Jul 20th, 2024, 01:20 PM
#1
Thread Starter
Hyperactive Member
Plotting Chosen Table Cells on a Chart
Consider there is a database linked to a datagridview which several numeral cells are being updated rapidly.
It is expected that WinFormApp plot only added ones to a listbox over time with simple line style on a chart control with no series at first and only if user "add" one or more members of datasource from an All_IDs_ComboBox (it only contains the primarykey of table it is dropdown) to a listbox. "Value" field/column corresponding to items of the listbox should be added as series points now. Finally there is a "Remove" button to exclude the item from the listbox and also delete its related series on chart. How can I achieve this in vb?
Following layout and some sequential directions was intended to getting the idea and for a better understanding:
Last edited by pourkascheff; Jul 23rd, 2024 at 09:24 AM.
-
Jul 20th, 2024, 04:04 PM
#2
Thread Starter
Hyperactive Member
Re: Plotting selected cells on a chart
What I've tried:
- Recording a specific cell with fixed unsorted location (also need to be fixed) as an already existed series.
Code:
If Resume.Checked Then
If Not OverTime.Checked Then
ChartControl1.Series(0).Points.AddPoint(ChartControl1.Series(0).Points.Count + 1, CDbl(SomeValue))
Else
ChartControl1.Series(0).Points.AddPoint(Now, CDbl(SomeValue))
End If
End If
A) Based on an imaginary flowchart, I need to know how to add and remove items in a listbox as well as series in a chart. Then in all_table_cells_update event, in a "for" loop handling each row, FindStringExact them all individually and adding new point is required. Is it something else? Please tell me. (If I could write it down myself, you're gonna see it below this line)
B) ComboBoxes does not have the feature of binding a DataSource as its collection like ListBox does. Does it make any difference? I mean ComboBoxes seemed to be the right control do do that. Less space occupying, AutoConplete entered text and a DropDown preview is a big deal. What would be the wisest decision here?
Last edited by pourkascheff; Jul 22nd, 2024 at 10:07 AM.
-
Jul 22nd, 2024, 03:47 PM
#3
Thread Starter
Hyperactive Member
Re: Plotting selected cells on a chart
Paragraph B) solved by using a 3rd party DevExpress "SearchLookUpEdit" control. I only manually bind it to a table in another form.
Code:
Public Class ConceptForm
Sub New()
InitializeComponent()
Me.MainTableTableAdapter.Fill(Me.Database1DataSet.MainTable)
End Sub
Private Sub TagList_SelectedIndexChanged(sender As Object, e As EventArgs) Handles TagList.SelectedIndexChanged
If TagList.Items.Count <> 0 Then
RemoveButton.Enabled = True
End If
End Sub
Private Sub TagFinder_EditValueChanged(sender As Object, e As EventArgs) Handles TagFinder.EditValueChanged
If TagFinder.Text = "" Then
AddButton.Enabled = False
Else
AddButton.Enabled = True
End If
End Sub
Private Sub AddButton_Click(sender As Object, e As EventArgs) Handles AddButton.Click
If TagList.FindStringExact(TagFinder.Text) = -1 Then 'Avoid Repetetives
TagList.Items.Add(TagFinder.Text)
ChartControl1.Series.Add(TagFinder.Text, DevExpress.XtraCharts.ViewType.Line)
End If
TagFinder.Text = "" 'Renew
End Sub
Private Sub RemoveButton_Click(sender As Object, e As EventArgs) Handles RemoveButton.Click
ChartControl1.Series.RemoveAt(TagList.SelectedIndex)
TagList.Items.Remove(TagList.SelectedItem)
If TagList.Items.Count = 0 Then
RemoveButton.Enabled = False
End If
End Sub
End Class
A) Overall mechanism - including: finding an ID to record, visually listing it then assigning a series to it and also ability to remove it with with its series - is working properly now using code above, But it misses the getting data core which is not mandatorily binding-sensitive way to handle value change event. Whether it is a one-way direction (reading only not writing on db)
It is possible via a timer (to also achieve a variable timeframe feature) and in every ticks, it adds value point(s) (of added "Field1" or name(s) to the list) to the corresponding series of the chart. Following "For" loop should do the thing but due to error on redlined part (not a real statement), I'm not sure how to access the value of Row = Name that 'i' returns and Column = "Field1" locates. In another mean how you people access cells of a table not involving DGV? (Or with DGV, in worst scenario)
Code:
Private Sub PlayPause_CheckedChanged(sender As Object, e As EventArgs) Handles PlayPause.CheckedChanged
If PlayPause.Checked Then
Timer1.Enabled = True
Else
Timer1.Enabled = False
End If
End Sub
Private Sub Timer1_Tick(sender As Object, e As EventArgs) Handles Timer1.Tick
If TagList.Items.Count <> 0 Then
For i = 0 To TagList.Items.Count - 1 'Cycle for all series
ChartControl1.Series(i).Points.AddPoint(ChartControl1.Series(i).Points.Count, CDbl(CellValue))
Next
End If
End Sub
Last edited by pourkascheff; Jul 23rd, 2024 at 02:02 PM.
-
Jul 23rd, 2024, 02:30 PM
#4
Thread Starter
Hyperactive Member
Re: Plotting Chosen Table Cells on a Chart
I found a way, but it is a non efficient way. All other better approaches are appreciated and welcome here. It's kind of like I'm thinking loudly here :-)
Last edited by pourkascheff; Jul 23rd, 2024 at 02:34 PM.
Tags for this Thread
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|