I am creating a StackedArea chart in VB.NET and I have some data rows which contain all 0 but one value which is for example 10.
When I draw these values, I loop over all these values, draw a zero and then continue with the next point. An example data row looks like this:
"january",0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.03,0.10,0.00,0.00,0.67,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00
As one can see in the in the blue line, there is still something (let's say 1px) displayed, even if the values are all 0.
My code to draw these series looks the following:
Chart.Series.Add(item(1))
For i = 2 To 25
Dim cell = worksheet.Cells(item(7), i)
Chart.Series(k - 1).Points.Add(cell.Value)
Next
Chart.Series(k - 1).ChartType = SeriesChartType.StackedArea
Chart.Series(k - 1).BorderWidth = 0
Does anyone have any idea what is going on? Thanks in advance.
Related
I have a grid view which has 3000 rows and one checkbox column and 2 textbox column.
I have a parameter list around say around 1700. it varies sometimes 5 or 10.
So I need to compare the list to the grid view and set the 1st checkbox column to true.
I use the compare and select method like below code which works well for a small number of parameter like 50,70
If Paramlist.Count > 0 Then
Dim row As Integer = 0
For Each listItem In Paramlist
Do While (row < gridview1.RowCount)
If Trim(gridview1.Rows(row).Cells(1).Value) = Trim(listItem) Then
gridview1.Rows(row).Cells(0).Value = True
Exit Do
End If
row = row + 1
Loop
Next
End If
It takes a lot of time to compare and set gridCheckbox value to true when I do it with more parameter list and the application seems like it is hanging when the user uses it.
Could anyone suggest me a faster way with less time complexity / best practice to set the grid check box value to true in the grid view.
[UPDATE]
I have attached a image of the exception thrown.
System.Invocation.TargetInvocationException
Currently I have a worksheet which has different colored cells in it like the one below:
[currentsheet] http://imgur.com/na6nvNH
I am using an array to count the colored cells per column. Here is my a snippet of my code:
Dim difference(0 To 41) As Long
For Each mycell In ActiveWorkbook.Worksheets("Differences").UsedRange
Dim col As Long
col = mycell.Column
If ActiveWorkbook.Worksheets("Differences").Cells(mycell.Row,mycell.Column).Interior.Color = vbRed Then
difference(col) = difference(col) + 1
End If
Next mycell
Sheets("Summary").Cells(47, 3) = difference(0)
Sheets("Summary").Cells(48, 3) = difference(1)
Sheets("Summary").Cells(49, 3) = difference(2)
etc.
Which will list the amount of colored cells I have per column. I need help breaking this down so I can create a table which shows the number of colored cells per department. I have no idea on how to do this!
To make it easier to view I am looking to create this:
[FinalSheet] http://imgur.com/i6W60m7
I should add: the amount of rows within the sheet can vary, they can also vary per department
Tried applying a column filter beginning with the first department and then counting the colored cells once the filter was applied, however since I am looking at every cell in the code above the result is still per column.
For anyone looking for an answer to this, a rather long method. However, I applied a filter and then set the range to only the visible cells instead of the used range in the whole worksheet
It seems it would be a lot easier to use a multi dimensional array, so you would have Array(4,7) so some sudo code might look like. I could do real code, but you seem to know what your doing.
Select Case mycell.row
Case 1
Array(1,Col) = Array(1,Col) + 1
Case 2
Array(1,Col) = Array(1,Col) + 1
Case 3
Array(2,Col) = Array(2,Col) + 1
end select
The trick to a multi dimensional array is to think of it like a spread sheet, (2,2) = 3 rows, by 3 columns ... (3 because arrays start at 0) The beauty of it is, if you do it this way when it comes to extract the data you simply put a double loop
For I =0 to Ubound(Array)
For II = 0 to Ubound(Array,2)
Cell(I,II).Value = Array(I,II)
next
next
Thank you for your time spending at my question. My issue was, I was trying to make some records into BLACK & GRAY color based on some condition. But while doing, I am able to make BLACK color for all the records but leaving last record. Hence, I am missing to color-out the last record. I want to make all the records to BLACK in color. Here is my code. Please find it.
For K = 1 To lvMergeGroup.ListItems.Count
If ptrDataItem.ValidTo = "xxxxxxxxxxx" And ptrDataItem.StatusIndicator = "A" And ptrDataItem.UpdateTimeStamp = "xxxxxxxxxxx" Then
lvMergeGroup.ListItems.Item(K).ForeColor = System.Convert.ToUInt32(System.Drawing.ColorTranslator.ToOle(System.Drawing.Color.Black))
Else
lvMergeGroup.ListItems.Item(K).ForeColor = System.Convert.ToUInt32(System.Drawing.ColorTranslator.ToOle(System.Drawing.Color.Gray))
End If
Next K
Change your loop to
K = 0 To lvMergeGroup.ListItems.Count -1
Collections start at position 0
You could also use a for each loop, which will also give you access to each item individually.
For Each item In lvMergeGroup.ListItems
'code for 'item'
Next
I'm trying to make a program where a user inputs numbers into a subtraction equation and the program tells them if they are right or wrong and what the correct answer is in a label. There are 20 different equations with 3 text boxes each. The first two text boxes are for the two numbers that are being subtracted and the third text box is the answer. I declared them into a array but I can't figure out how make them subtract. The code i have so far is:
Dim i As Integer
Dim txtNumber1() As TextBox = {txt1Number1, txt2Number1, txt3Number1, txt4Number1, txt5Number1, txt6Number1, txt7Number1, txt8Number1, txt9Number1, txt10Number1, txt11Number1, txt12Number1, txt13Number1, txt14Number1, txt15Number1, txt16Number1, txt17Number1, txt18Number1, txt19Number1, txt20Number1}
Dim txtNumber2() As TextBox = {txt1Number2, txt2Number2, txt3Number2, txt4Number2, txt5Number2, txt6Number2, txt7Number2, txt8Number2, txt9Number2, txt10Number2, txt11Number2, txt12Number2, txt13Number2, txt14Number2, txt15Number2, txt16Number2, txt17Number2, txt18Number2, txt19Number2, txt20Number2}
Dim txtAnswer() As TextBox = {txt1Answer, txt2Answer, txt3Answer, txt4Answer, txt5Answer, txt6Answer, txt7Answer, txt8Answer, txt9Answer, txt10Answer, txt11Answer, txt12Answer, txt13Answer, txt14Answer, txt15Answer, txt16Answer, txt17Answer, txt18Answer, txt19Answer, txt20Answer}
Dim intAnswer() As Integer
For i = 0 To txtNumber1.Length - 1
intAnswer(i) = txtNumber1(i) - txtNumber2(i)
Next
I also can't figure out how i would make each answer display into a label. I think it would be some like
If intAnswer(0) = txtAnswer(0) Then
Me.lblAnswer1.Text = "Correct:" & intAnswer(0)
Else
Me.lblAnswer1.Text = "Incorrect:" & intAnswer(0)
End If
But I'm not sure how i would loop that to make it do all 20 labels, or would i just need to have it 20 different times, one for each label.
Thanks for the help.
Best to create a user control with 3 labels and 3 textboxes on each. Then you only need to code this much, and wrap this logic in a loop to repeat as many times as you want. Basically, narrow down your problem to "I only have 1 equation", solve it using this approach, the rest is as easy as using adding a loop to your code.
I know this may sound trivial but I just can't find an answer to it.
I have a rdlc report in which I like to alternate row background color and for this I've used the following formula:
=iif(RowNumber(Nothing) Mod 2, "#e5e5e5", "White")
I also need to hide some rows and for this I use the following formula:
= Fields!MeanAeb.Value <> ""
where MeanAeb is a field in my report. My problem is that rowNumber also counts the hidden rows, so my table may have two consecutive rows with the same background. is there a way to take only visible rows into account?
So if anyone has the same problem, I have an answer;
in the Code section of your ReportProperties add the following
Dim customRowNumber as Integer = 0
Dim previousRowNumber as integer = 0
Function CustomRowCounter(conditionToTest as Boolean, rowNumbner as Integer) as Integer
if(conditionToTest and rowNumbner <> previousRowNumber)
customRowNumber = customRowNumber + 1
previousRowNumber = rowNumbner
end if
return customRowNumber
End Function
then on the background field in your column properties add this condition:
=iif(Code.CustomRowCounter(Fields!MeanAeb.Value="",RowNumber(nothing)) Mod 2, "#e5e5e5", "White")
this is nice because you can add any condition you like in place of Fields!MeanAeb.Value="". Just remember to use the inverse of the condition in your rowVisibility field, otherwise you may cause strange effects.
Oh and if you want a chess board look to your report just drop the previousRowNumber :)