I am using a loop to add series to a chart based on column name
With ds.Tables("MyTable")
Dim i As Integer = 0
For Each column As DataColumn In .Columns
If column.ColumnName Like "S1_*" Then
Chart2.Series.Add(column.ColumnName)
Chart2.Series(column.ColumnName).YValueMembers = column.ColumnName
Chart2.Series(column.ColumnName).ChartType = DataVisualization.Charting.SeriesChartType.Line
Chart2.Series(column.ColumnName).BorderWidth = 3
Chart2.Series(column.ColumnName).XValueMember = .Columns("DateTime").ToString
Chart2.Series(column.ColumnName).IsXValueIndexed = True
End If
Next
When changing the series names manually everything works fine
With Chart2
.Series(0).Name = "Series Name 1"
.Series(1).Name = "Series Name 2"
.Series(2).Name = "Series Name 3"
End With
The problem occurs when i change the way the series names are changed. If i change the series names within a loop
For i = 0 To ds.Tables("Qs").Rows.Count - 1
For x = 0 To Chart2.Series.Count - 1
If Chart2.Series(x).Name = ds.Tables("Qs").Rows(x).Item("Q_Name") Then
Chart2.Series(x).Name = ds.Tables("Qs").Rows(x).Item("Q_Text")
End If
Next
Next
I get the following error when viewing the chart
An unhandled exception of type 'System.ArgumentException' occurred in System.Windows.Forms.DataVisualization.dll
Additional information: Cannot display indexed series (XValueIndexed = true) on the same axis if they are not aligned.A chart element with the name 'Series Name 1' could not be found in the 'SeriesCollection'.
The Series names are being updated correctly within in the loop and i can see teh chart if I remove the Chart2.Series(column.ColumnName).IsXValueIndexed = True. The only difference I can see is how the series names are being changed.
All help / comments are appreciated
Visual Basic starts indexing at 1. Try replacing
.Series(0).Name = "Series Name 1"
with
.Series(1).Name = "Series Name 1"
and likewise for the other series.
Related
I want to create a number of resources using terraform depending which number the user enters. The number have to be between 2 and 5.
I tried:
in vars.tf:
variable "user_count" {
type = number
default = 2
description = "How many number of VMs to create (minimum 2 and no more than 5): "
}
The problem here is its creates the resources with the default number 2.
Another case:
variable "user_count" {
type = number
description = "How many number of VMs to create (minimum 2 and no more than 5): "
}
Here, without the default parameter. I get the message/description, but I/the user can enter anything!
How to make this possible? - the user get a message and verify the number is between 2 and 5, else the resources will not be created.
Any help is appreciate - I am really stuck in it!
You may try custom validation
variable "user_count" {
type = number
description = "How many number of VMs to create (minimum 2 and no more than 5): "
validation {
condition = var.user_count > 1 && var.user_count < 6
error_message = "Validation condition of the user_count variable did not meet."
}
}
But maybe better option instead of checking number, will be variable as string and regex to check if value is 2,3,4 or 5.
variable "user_count" {
type = string
description = "How many number of VMs to create (minimum 2 and no more than 5): "
validation {
# regex(...) fails if it cannot find a match
condition = can(regex("2|3|4|5", var.user_count))
error_message = "Validation condition of the user_count variable did not meet."
}
}
The macro attempts to filter Sheet "Temp" for one Criteria at a time (PE, AR, DC,FI), and copy column 5 that contains non-duplicate data into another sheet "Detail". Please help me understand two issues. (1) The macro does correct filtering for each of the 4 criteria. However, the filtered list for each of the criteria always contains the first item from the filtered list of the very first criteria "PE". I.e. the filtered list for criteria 2, "AR", contains all items in AR, but starts with the first item in "PE". There's a header row, but it doesn't seem to make a difference. How can I get rid of that first item in all cases except when filtering for "PE" (where it belongs)? (2) I would like to be able to count and store the number of visible rows for each filtered list. I would like to be able to paste each filtered list into another spreadsheet ("Detail"), starting in cell A4. Each consecutive list should start two rows below the list that was just pasted. For example, if the first list contains 16 items, then the next list should start in cell A22 (A4+16+2). For some reason, copiedrows (used to remember number of rows in a filtered list) is correct the first time around (=16), but not the second time (=1?). It looks like q's 1 & 2 are related. Perhaps, if I figure out #1, I can do something about #2. I reviewed exiting posts on Autofiltering, but still feel a bit stuck here. Really appreciate your help!
Sub FilterCategories()
Dim LastRow As Long
Dim startpos As Integer
Dim k As Integer
Dim copiedrows(1 To 4) As Long
Dim AG(1 To 4) As String
Dim rng As Range
AG(1) = "PE"
AG(2) = "AR"
AG(3) = "DC"
AG(4) = "FI"
'Autofilter based on each AG and copy over to 'Detail'. Create temporary
sheet for filtering.
startpos = 4
For k = LBound(AG) To UBound(AG)
Application.DisplayAlerts = False
On Error Resume Next
Sheets("Temp").Delete
Sheets("Lookup").AutoFilterMode = False
Sheets("Lookup").Copy After:=Sheets("Lookup")
ActiveSheet.Name = "Temp"
With Sheets("Temp")
AutoFilterMode = False
LastRow = .Cells(.Rows.Count, "A").End(xlUp).Row
With .Range("A2:E" & LastRow)
.AutoFilter Field:=4, Criteria1:=AG(k)
.RemoveDuplicates Columns:=5
.Columns(5).SpecialCells(xlCellTypeVisible).Copy
Destination:=Sheets("Detail").Range("A" & startpos)
copiedrows(k) = .SpecialCells(xlCellTypeVisible).Rows.Count
Debug.Print copiedrows(k)
startpos = copiedrows(k) + 6
Debug.Print startpos
End With
End With
Next
End Sub
I have a active report that has two column named Deposit and Withdrawal.I want to get sum of both the columns at last page of active report. I have done some code in ReportStart event
var fldDepositTotal = ar.Sections["gfDetail"].Controls["fldDepositTotal"] as DataDynamics.ActiveReports.TextBox;
var fldWithdrawalTotal = ar.Sections["gfDetail"].Controls["fldWithdrawalTotal"] as DataDynamics.ActiveReports.TextBox;
fldDepositTotal.DataField = "AmountD"; // Your datafield value
fldDepositTotal.SummaryFunc = SummaryFunc.Sum;
fldDepositTotal.SummaryGroup = "ghDetail";
fldDepositTotal.SummaryRunning = SummaryRunning.Group;
fldDepositTotal.SummaryType = SummaryType.GrandTotal;
fldWithdrawalTotal.DataField = "AmountW"; // Your datafield value
fldWithdrawalTotal.SummaryFunc = SummaryFunc.Sum;
fldWithdrawalTotal.SummaryGroup = "ghDetail";
fldWithdrawalTotal.SummaryRunning = SummaryRunning.Group;
fldWithdrawalTotal.SummaryType = SummaryType.GrandTotal;
I have make it in report footer also but still not getting sum of Deposit and Withdrawal amount. How can I get sum of columns?
The SummaryRunning setting basically defines when to reset the accumulating total back to zero. In the case of a grand total value at the report level you don't want the value to be reset - you want it to continue accumulating throughout the entire report. So you don't need the SummaryGroup and SummaryRunning properties here. So based on the sample in the SummaryType property's documentation you can set the SummaryGroup and SummaryRunning properties as follows:
fldDepositTotal.DataField = "AmountD";
fldDepositTotal.SummaryFunc = SummaryFunc.Sum;
fldDepositTotal.SummaryGroup = null;
fldDepositTotal.SummaryRunning = SummaryRunning.None;
fldDepositTotal.SummaryType = SummaryType.GrandTotal;
I want to specify a formula for the display string property of an object on my report, however I want to use it to format the data that would otherwise show up if I were not using this formula. Is there a keyword or anything I can reference within the formula that represents what would normally be displayed?
You might need to create a formula field and reference your database field within it:
for summarized fields, I use min(#cellVal) in the crosstab:
dim cVal as number
cval = {vw_rpt_waitlist.CountOfRecipientID}
if cval < 0 then
formula = " "
elseif cval = 0 then
formula = ""
elseif cval < 5 then
formula = "< 5"
else
formula = cstr(cval,0,",")
end if
and in the rows list, to modify the sorting:
if {vw_rpt_waitlist.SupportCode} < 100 then
formula = {vw_rpt_waitlist.description}
else
formula = "z" + totext({vw_rpt_waitlist.SupportCode}) + {vw_rpt_waitlist.description}
end if
It doesn't seem this is possible as far as I've been able to tell.
I have datagrid with two datagridviewcombo column, one column is dynamic fill and one has fixed hardcoded values.
The problem is I can't set the value of dynamic GridViewComboBox, when I try to set it generates continues errors.
System.FormateException: DataGridViewComboBoxCell Value is not valid.
My code to load the grid is
Dim dt As DataTable
dt = GetDataTable("Select valuecol,displayCol From mytable") 'GetDataTable gives me datatable
cmbAntibiotics.DataSource = dt
cmbAntibiotics.DisplayMember = "Antibiotics"
cmbAntibiotics.ValueMember = "AntibioticsID"
Dim Index As Integer
Dim dgr As DataGridViewRow
For Each dr As DataRow In dtFromDB.Rows 'This datatable is filled with database
Index = dtFromDB.Rows.Count - 1
GRDAntimicrobials.Rows.Add()
GRDAntimicrobials.Rows(Index).Cells("cmbAntibiotics").Value = dr("AntibioticsID").ToString 'At this point it shows value (1,2,3) rather then showing its display members
GRDAntimicrobials.Rows(Index).Cells("AntibioticsStatus").Value = dr("AntibioticsStatus").ToString
Next
Pls help with me
It seems like you're trying to assign the value to whatever there is on the cell rather than instantiate the object that resides in the cell and then assign its value. I would try something like this:
Dim vComboBoxColumn As DropDownList = DirectCast(GRDAntimicrobials.Rows(index).Cells("cmbAntibiotics"))
vComboBoxColumn.Value = dr("AntibioticsStatus").ToString