Report vewier cannot add parameters - vb.net

I have managed to set a dataset to my tablix on my report viewer that will hold all items belonging to a bill. The issue I present you with is I cannot seem to add any parameters to my textboxes in my .rdlc report. Is this because I have added a connection to my database? Before I added my connection I could easily add parameters, but not anymore. Take a look at my report:
All the red rectangles is where I would usually have my parameters. Is there a way to programmatically do this?
Dim rpJobNum = New ReportParameter("tbJobNo", JobNum)
rv.rvRdlc.LocalReport.SetParameters(rpJobNum)
rv is my report viewer form
rvRdlc is my report viewer control
tbJobNo is my textbox' job number name
JobNum is a variable which holds the respective value (ex: 10000)
If I execute that,I will receive an error:
Any idea why I cannot seem to add any parameter controls? Perhaps there's another way of doing this?

Figured out why I couldn't add parameters. Pretty noob stuff on my part.
Go to View > Report Data
Or... Ctrl + Alt + D
My apologies, but, I'll answer this if it can help someone!

Dim parmlist As New List(Of ReportParameter)()
parmlist.Add(New ReportParameter("tbJobNo ", JobNum))
print.ReportViewer1.LocalReport.SetParameters(parmlist)
you need to create a list, as i did here

Related

Fill a boolean array from checkbox control array

My program creates an array of checkboxes at runtime as shown below:
For Looper = 0 To 36
Dim Ex1ConfigCheck As New CheckBox
frmSetup.Controls.Add(Ex1ConfigCheck) ' Add Control to from
Ex1ConfigCheck.Top = (Looper + 45) + (Looper * 18) ' Set Location
Ex1ConfigCheck.Left = 210
Ex1ConfigCheck.Text = Setup.ExCheckName(Looper) ' Set Text property from strArray
Next
This is where I don't know how to proceed.
I would like to fill a boolean array (ex. MyBoolean(37)) with the value of Ex1configCheck().Checked. The reason I would like to fill another array is because I need to be able to reference the value of the checkboxes in other parts of the code but can't access them until they are created. Also, I plan on saving the array out to a binary file.
Could someone point me in the right direction please?
If there are no other CheckBoxes in the same container as those ones then you can do this:
Dim flags = Me.Controls.OfType(Of CheckBox)().
Select(Function(cb) cb.Checked).
ToArray()
If the controls are in a different container than the form itself, replace Me with that container.
As suggested by #Jimi, you could also create a List(Of CheckBox) and assign that to a field, populating it when you create the controls. You can then use that list instead of creating one on demand:
Dim flags = myCheckBoxList.Select(Function(cb) cb.Checked).
ToArray()
Of course, if you know exactly how many CheckBoxes you are going to be adding, why do you need to wait until run time to create them? Why can't you create them at design time and then modify them at run time? You usually only create controls at run time if you don't know how many there will be until run time, but that seems not to be the case here.
Thanks all for your answers and comments. I always have a fear of being roasted when I ask what some may consider a simple question online.
I have found an alternative way of accomplishing my task. Instead of creating 8 "Arrays" of checkboxes, I have learned of a very simple control available called "CheckedListBox".
I really didn't need to create the checkboxes at runtime but was trying to find an easier way to create 8 groups of 37 checkboxes without having to manually name and set the properties of each one during design. I also wanted to be able to index them in my code to be able to update and read the value using simple loops. I could have done this by creating arrays of CheckBox but again, I would have had to manually initialize the arrays.
Once I found the CheckedListBox, I was able to accomplish what I want very quickly. I only had to set the properties of the 8 "groups" (CheckedListBox's) and fill them using the items property. The ListBox essentially created a List like Jimi suggested automatically and I can index thru each list with a loop as desired. Jimi's suggestion actually lead me to finding the CheckedListBox while I was searching for more information on using "List(of CheckBox)".
Sometimes talking to others helps me find the right questions to ask. Google was able to figure out what I wanted when I searched for "List(of CheckBox)". (:

Change the Column width and Position programmatically in Crystal Reports

I want to create a report that has dynamic fields (columns). in the simpler words, there are 15 optional fields for user and the user will select 6 of them to be displayed in report.
so, for solution, I added all the columns in the report. and now I want to hide all non-selected columns and also change the width and position of the visible columns.
how can I do that in vb.net 2010 by coding?
As far as the width is concerned, you could use something like this, which will change the height and width (0 of course will hide it, so change it to a value that suits you).
Dim RptDoc As New ReportDocument
Dim _fldName As FieldObject
_fldName = RptDoc.ReportDefinition.ReportObjects("fieldObjectName")
_fldName.Width = 0
_fldName.Height = 0
About moving an object, you could try something like this:
myReport _myReport = new myReport ();
myReport .Section1.ReportObjects["myline"].Top = 10;
You need to be aware of the Section naming in your report and the correct line reference.
If you want just to visualize the data I would suggest you to use a grid. Crystal report is good for static structures. If you need to export the grid to a pdf or Excel then you can use this tool:
http://r-tag.com/Pages/BlogPost/1
Get a free license here: http://r-tag.com/Pages/CommunityEdition.aspx

Get Values from Listbox for if functions

Hey guys very new here.
Have a listbox that gets account names from a specific game server using this command line
Dim apikeyinfo As APIKeyInfo = api.getApiKeyInfo()
lstbxCharacters.DataSource = apikeyinfo.Characters
this code gets all the characters in a single account by displaying it in a listbox.
Now i would like to reference a character from the lisbox but not sure how
Any method such as Listbox.Get to get the value and compare it with something else?
Thanks
you can try something like
lstbxCharacters.SelectedItem
Update
To read the data from the listbox I think there are multiple ways (Assuming that it is readable).
-> Usually listbox display strings, so it should work to read to a string variable
Dim a_string as Strin = lstbxCharacters.SelectedItem
also you may like to add a small check before, assuring that an Item is currently selected:
If lstbxCharacters.SelectedIndex < 0 then return
This jumps out of current sub if no item is selected
And finally, to read the first entry, you can also do it this way:
a_string = lstbxCharacters.Items(0)
if it returns objects, then instead of accessing the object directly, it may work to do
a_string = lstbxCharacters.Items(0).ToString
(most objects allow a .ToString() Function )
Here two ideas for different solutions:
As a user commented, you could access the DataSource directly + the information which listIndex was selected. But if you do so, then maybe it is more easy (if you need to access it anyways, to go with solution 2)
Create a variable of type list(Of some_object) and fill it with the data from the datasource. It will take some time to do this, but if you define for the class some_object a function ToString, then you can fill all objects directly to the lstbxCharacters, and access them without any worries, by doing CType(lstbxCharacters.SelectedItem, some_object)
Update 2
If with reference you mean to access further information from the datasource, then you need to build some kind of query, or set the content of the listbox in relation to another control that shows the database content (in that way the listbox lstbxCharacters would act like a filter)

VB.NET / Windows Forms - Data from user input to DataReport?

I'm developing a windows forms application using VB.NET. I'm currently working on DataReport (by Microsoft, not Crystal). Everything works fine when using DataSet as DataSource. But I have a question on how am I going to put data to my DataReport from a user input? Preferably when the user is on the act of printing(clicking the print button in the ReportViewer), a Form will pop-up and ask him for input. That input I'm talking about is random names of people, and we don't have to track their names so there's no reason to put it on the database.
Here's my simple setup:
MainForm.vb (Form)
MyReportViewer (ReportViewer)
MyReport.rdlc (DataReport)
InputForm (Form)
MyInputBox (TextBox)
If it is impossible to do it on the act of printing. Maybe on the MainForm_Load event or before the generation of report can do.
I've searched the net for an hour but I'm out of luck.
I've found the answer, it's called ReportParameters.
Here's how to set it:
'Get input from user...
Dim OneParameter As String = InputBox("Enter something to display on report!", "Report Parameter")
'Prepare report parameters... The `SetParameters` requires array of `ReportParameter`...
Dim ReportParameters As New List(Of ReportParameter)
'Add the user input to `ReportParameter` array...
ReportParameters.Add(New ReportParameter("OneParameter", OneParameter, True))
'Set the `ReportParameters` of the `ReportViewer`...
FormWithReportViewer.TheReportViewer.LocalReport.SetParameters(ReportParameters)
FormWithReportViewer.Show()
FormWithReportViewer.Focus()
On the DataReport(.rdlc), we have to add a ReportParameters (Menu>Report>Report Parameters). The same name (OneParameter) should be used to avoid error. We can now use the parameter in our textbox, just put =Parameters!OneParameter.Value and we're done!
Note: We have to set the report parameters before rendering the report. If we cannot avoid that, refresh the report after adding parameters so it will be updated:
FormWithReportViewer.TheReportViewer.RefreshReport

How to detect Updated textbox with Linq

-->VB.Net VS2010
If this is a stupid question, then let me know. I can't just figure it out.
First of all, this is my question. How do I detect the changed value on those text boxes?
I have an idea that I create a another string values that have the original values and compare them right before saving or form closing event. This sample just have 3 text boxes, but I have 50 + text boxes on my one form. I can do it that way, but that is not really smart idea.
Can I use abcDB.SubmitChanges() to detect any data changes on text boxes?
Dim sqlQuery = (From obj in abcDB.HelloWorld
Select obj.Fname, obj.Lname, obj.PhoneNumber).FirstOrDefault()
me.textboxFname.text = sqlQuery.Fname
me.textboxLname.text = sqlQuery.Lname
me.textboxPhoneNumber.text = sqlQuery.PhoneNumber
What you really want to do is called 'data binding'. Lots of tutorials about that aroud the web and any book about VB.NET will have at least 1 chapter dedicated to it.