Listview with Dynamic Data - windows-phone-8.1

I got a model that should populate the listview. Depending on the type I need to show the list of possible answers.
{
"Question" (string): ("Please choose the one of the followings best suitable to your situation.")
Type (enum) (Type.Radio, Type.FreeText, Type.Number, Type.Checkbox)
List<Answers> ({"It was cold inside.",
"It was cold but the heaters turned on after asking."
"It was warm" })
RequiresComments (bool) (true)
}
The amount of questions will come from server. It might be 70 question and some of them as radio, some of them as checkbox, some of them just free text.
I did this on Android and iOS but I have no idea how to do is on Windows Phone 8.1. Can anyone show me an example or point me into right direction?

In your view have a radio buttons with vales from enum. Once the user selects the type fetch the answers from server.
After fetching the list of answers. Set the listview's(in your view) Itemssource to the list of answers that you obtained.
The comment part,you can use the bool and change the visibility of the comment textbox(in your view) using a converter.

Related

How to retrieve selected answer from a drop-down question in Google Forms

I am creating a Google form where the first 3 questions are linked. With this in mind, I need therefore to be able to access the response for question 1 to use it as a parameter for question 2 and so on.
I am using a ListItem object where the object contains the names of continents in question 1, countries in that continent in question 2 and universities in that country in question 3. I've searched around and haven't found any way of accessing the answers as the user selects them.
I've thought about using sections to maybe get the information from one section to another but I haven't managed to do that either.
What I would like, in a perfect world, is the user to select an answer from question 1, depending on that answer, the choices for question 2 will change and same for question 2 with question 3.
Selected Value from DropDown in standard html form
var selectElement = document.getElementById('selectId');
var selectedValue = selectElement.options[selectElement.selectedIndex].value;
Selected Value from DropDown in Google Form
It can't be done because you can't interact with running Google Form

Passing Variables Between Forms

Forgive me if this has already been asked- I can’t seem to find a well written answer.
I am developing a small application for personal use.
Essentially what I have is two forms. Form 1 is a master view of all my contacts listed on a data grid view. Form 2 will be loaded on the cell/row double click of a particular record in order to edit it’s details.
My question is, what is the best practice/method for achieving this? I have seen many different methods.
Should I:
Pass only the primary key of the selected row then populate the fields on form 2 load
Pass all fields as a variable within a class then populate form 2 from that
Maybe I’m headed in the complete wrong direction though.
I have tried both ways, but wondering what the best method is for scalability.
My personal preference would be to pass a datarow into the opening argument of the form (rather than the PK / all the variables). You can then use the datarow inside your Form2 to bind to your controls or set their values, whichever you think is appropriate.
There are some useful examples on working with a datarow if you're unsure, alternatively you can also check out Microsoft Docs.
Public Sub New(ByVal row As DataRow)
InitializeComponent()
' your code for working with row here
End Sub
Edit:
In terms of "Binding" vs "Setting", you can either have your controls linked to your data to be two way (as you edit the data in a control at run time you alter the data in your database) or you can just set the values of the controls.
E.G. TextBox1.Text = row(0)("ColumnName")
You can find more on data binding on the Microsoft Docs page

How to implement 'To' field functionality present in Windows Phone 8 inbuild message application

I need to implement functionality similar to 'To' field present in the Windows Phone 8 in build message application.
Whenever user wants to remove any name from 'To' field, he needs to tap on that name then one message pop up will be displayed with remove, open, copy and cancel
User cannot place the cursor in between of the name, once the name is ended with the semicolon
Can anyone suggest me the approach to implement this feature?
Thanks in advance
This is a custom control you would have to write. It is not delivered along the other Windows Phone Controls.
Here is a scetch of how you could achieve this: The custom control is a combination of a TextBlock ("To:" Field) followed by a GridView, Followed by a TextBox (Input Field).
Now at the beginning, the GridView has no entries and is therefore not visible. If the user selects an Email from the type ahead or closes the input by a semicolon (listen to the KeyUp Event of the TextBox), your control logic creates an instance of a datamodel which then holds the ID, Email Address, Name and whatever you would need. This instance is then added to an ObservableCollection which is bound to the GridView. Having the ObservableCollection in place will result in an automatic display of the entry in the GridView. Now clear the TextBox and be prepared for the next entry.
The rest is only layout stuff to have no borders on your TextBox, have the GridView display the Names with Semicolons etc.
Finally react on GridView selections with the Popup to delete or Update its content.

MS Access 2007 - controlling UI behaviour after attempt to insert duplicate record

Creating a simple UI using MS Access, hoping to do minimal actual coding (actually helping a friend who is not a coder).
Simplified requirement: Single table, primary key is phone number, lots of other non-mandatory fields. Display a form allowing just the phone number to be entered, if a record with that key exists display the full record, if a record with that key does not exist bring up an form allowing the other fields to be entered for this phone number and hence create a new record.
Q1: Any simple way to achieve this kind of function? Example?
We've got some of this going with a standard form, can execute code if insertion fails, but a standard dialogue box is displayed warning about the duplciate key violation.
Q2: How can we trap that attempted insertion, avoid having the dialogue come up?
You will have to get your hands dirty and write some code to get this outcome. A starting point would be something like this presto code. Post back if you get stuck on any of the parts.
If fCheckIfRecordExists(lYourKey)=True then
Docmd.OpenForm “frmEditExistingRecord”
Else
Docmd.OpenForm “frmEnterNewRecord”
End if
Public function fCheckIfRecordExists (lYourKey as Long) as Boolean
‘Code to check if a record exists, simple method is to use dLookup or a count SQL statement with the criteria as the key you are trying to find
End function
EDIT:
First things first make a form with 1 text box called txtPhone_number and a command button called cmdSearch.
Next put this bit of code in the module behind the form
Public Function fDoes_record_exist(strPhone_number As String) As Boolean
If DCount("Phone_number", "tblYour_table", "Phone_number=" & strPhone_number) > 0 Then
fDoes_record_exist = True
Else
fDoes_record_exist = False
End If
End Function
Next you need to put some code behind the click event of the command button. This code can be expanded on to check for a valid phone number later if you want
If fDoes_record_exist(Me.txtPhone_number) = True Then
DoCmd.OpenForm "frmShow_existing_record"
Else
DoCmd.OpenForm "frmEnter_new_record"
End If
That should set you on your way nicely but post back if you run into problems
Here is an overview of the process with Access logic:
You need an unboud control labelled Phone in the form header, where user will be able to enter the phone number to search. You need to use the After_Update event of that control to trigger your search. There will be a second Phone control, bound this time, in the Detail section of the form for effective data entry/update.
Use the Form_Error event to intercept the error message when user tries to save a duplicate key, in order to display a nice message, and eventually Cancel his changes.
The advice from Kevin Ross to use VB Code is clearly one approach, and I think is appropropriate if we anticipate less trivial requirements in future. However I'm in a situation where I'm helping someone with zero coding background and hence if possible I'd prefer to let them use simple Macros rather than full-scale VB.
As it happens the functionality I require can be implemented with just Macros, and it depends on the suggestion from iDevelop.
The outline of the solution I used:
Create an InitialEntry form with no association to any particular table, it has:
a data entry field for the telephone number
a read-only text box where I can display a message
a button labelled Add
a button labelled Show
I write three macros:
A macro AlreadyExists that displays a message saying "We already that one"
A macro NewEntry that opens a data entry form for my table, in Add mode, and which copies the phone number from InitialEntry!TelephoneNumber
A macro TestForExisting this uses a condition
DCount("*","MyTable","[PhoneNumber] = [FormPhoneNumber] " ) > 0
to control whether to execute AlreadyExists, and a similar test to control whether to call NewEntry.
While this is not as efficient as VB, it does seem to be understandable by a non-coder, so at least we can implement our application.

MS Access 2003/2007 - Passing data through a variable on unbound forms vs. a hidden text box

Ok so I hope the title of the question matches what I about to ask, but here is what I am trying to get at:
So I have an access database that uses a number of unbound forms, and the purpose of the forms are to collect data and save to various tables with VBA click events using SQL statements (INSERT or UPDATE based on whether the ID of the record is present on the form in a hidden text box). When entering a new record (via INSERT), I get the row number with
MyRow = db.openrecordset("SELECT ##Identity")(0) 'thanks David
So you maybe getting the picture. If I have another form that relates to the first form in terms of the record, I just open a recordset and pass that value to another hidden text box.
So my question is, is there a better way to do this regarding passing that value (or just using that value) using a variable instead of this awkward method. So I realize a lot of folks are going to go with the obvious answer of, "Why not just make your forms bound instead of all this code"...and I am sure that is a valid answer, however I inherited this database which was already put together like this, and re-structuring it would be a daunting task.
Any and all advice, or learning resources are greatly appreciated, as they always are!
I use unbound controls on forms for all these kinds of values. The current solution of using an unbound form is sounder than using global or form level variables. If I recall the details correctly while debugging code and you hit the stop button you lose all global or form level variables. Or if the user hits an unhandled error.
Have you looked at OpenArgs?
DoCmd.OpenForm "Form1", , , , , , "Hello"