Originally posted by jpmcafee
Assigning a value to radio buttons
Collapse
X
-
Sure,
What I have is an employment information sheet. This is used for fraud cases. Essentially when you have several suspects that you are unaware of who actually comitted a crime, this is a tool to assist you in identifying who might most likley be the suspect. Currently we have this on paper form. I would like to create and application to do the same.
So what the paper looks like is:
This sheet has approx 8 verticle rows, at the top is a place to put the suspects name, this is to identify the subjects of the crime. Now down this row is a series of questions that are posed, these are realted to the individual. Such as position, Fulltime/parttime, tenure, age, etc. Now each one of the possible answers are waited based on the relivenace such as for Full Time/ Partime: if they are partime they would get a check mark in that column because that would indicate a need for money, more so than a fulltime employee.
Each one of these questions are along the same line. I have 24 questions in total. However on paper it is easy to check each of these boxes. In an application, I will have to provide these answers and weight them with a value I would think. At the bottom we simply count the check marks and the individual with the most check marks is who we would concentrate on first.
I hope this helps. Let me know your thoughts.
JoshComment
-
So Iam following up. I think I got away for this to work. I created a tabbed menu to start. The theory behind this is each tab will represent one suspect. As I need to add more suspects, I have created a button to add a new tab. So it will create a new tab each time clicked. Each of these tabs will have the same questions within the tab index. Now comes the tricky part. As before we used checkboxes and made a tage reference of A1-A5 and B1-B5 for each checkbox this is how we were able to sum them up. What i need to be able to accomplish now is a couple of things;
1. to be able to dynamically create a new tab with the same questions on each tabbed page ( I can create a new tab now I just need to figure out how to have the same questions on each page).
2. Have the application recognize it is a new tabbed page and apply a new tag value such as C1, D1, E1 etc.
3. Create a summary page that will pull in all of these results and display them in a text box.
If anyone can steer me in the right direction I will love you forever... :) Thank you all for your support.
J.Comment
-
Originally posted by jpmcafee1. to be able to dynamically create a new tab with the same questions on each tabbed page ( I can create a new tab now I just need to figure out how to have the same questions on each page).
You can create the controls on a page yourself: just look how VB does it. You can see this code by clicking the button on top of the Solution Explorer that says "Show All Files" (2nd button), and then click on the + in from of your form. Right-click on the Form.Designer.v b and view-code.
Here's a simple example, http://msdn2.microsoft.com/en-us/lib...55(VS.71).aspx. But, you need to add bunches, so you will need to have an array for each of your controls. Here's Microsoft's NOT simple solution, http://msdn2.microsoft.com/en-us/lib...00(VS.71).aspx. I would work thru both of these samples and understand them before continuing.
But, not following my own advice, I would (1)make a tabpage as a template - set to invisible, (2)have a generic list for each type of control, and (3)for a new tab page just iterate thru the template, adding a copy of each control to the appropriate list. Well, that's overwhelming: enough for today. If I get time, I'll try to make a demo.
=============== =============== =============== =
Totally changing the design: You could make all of this into a TreeView. Each subject would be a root node, the questions would be the second level, and the responses the third level. It would be infinitely easier to code.Attached FilesComment
-
Man you are great,
I did post a new topic afterwards with your second idea and I think I will try that.. somehow. So up to this point, I have created a tabbed form with two buttons. I will place about 10 tabs accross the top. I guess my next step would be to :
1. create the checkboxe form on each tab like before
2. find a away to hide the tabs (2-10) unless a button is pushed which should make each tab appear as the button is pushed.
3. create results page at the end as well that will be invisible and only shown when the results button is pushed.
So what I could use if anyone knows is a work around to make tabs appear and dissapear as a button is pushed.
I guess this is where I will start so any help would be great.. .Thanks again sammy.
Originally posted by SammyBA tabpage is a container, just like a form, so to addup a page you just do foreach control in pgA1.Controls
You can create the controls on a page yourself: just look how VB does it. You can see this code by clicking the button on top of the Solution Explorer that says "Show All Files" (2nd button), and then click on the + in from of your form. Right-click on the Form.Designer.v b and view-code.
Here's a simple example, http://msdn2.microsoft.com/en-us/lib...55(VS.71).aspx. But, you need to add bunches, so you will need to have an array for each of your controls. Here's Microsoft's NOT simple solution, http://msdn2.microsoft.com/en-us/lib...00(VS.71).aspx. I would work thru both of these samples and understand them before continuing.
But, not following my own advice, I would (1)make a tabpage as a template - set to invisible, (2)have a generic list for each type of control, and (3)for a new tab page just iterate thru the template, adding a copy of each control to the appropriate list. Well, that's overwhelming: enough for today. If I get time, I'll try to make a demo.
=============== =============== =============== =
Totally changing the design: You could make all of this into a TreeView. Each subject would be a root node, the questions would be the second level, and the responses the third level. It would be infinitely easier to code.Comment
-
Originally posted by jpmcafeeSo what I could use if anyone knows is a work around to make tabs appear and dissapear as a button is pushed.
sammy.
Code:Public Class Form1 Private cPages As New List(Of TabPage)() Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load ' Save each tab in cPages For i As Integer = 0 To TabControl1.TabCount - 1 cPages.Add(TabControl1.TabPages(i)) 'Save the tab Next i ' Remove all but First to make them invisible For i As Integer = TabControl1.TabCount - 1 To 1 Step -1 TabControl1.Controls.RemoveAt(i) Next i End Sub Private Sub BtnAdd_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles BtnAdd.Click TabControl1.Controls.Add(cPages(TabControl1.TabCount)) If TabControl1.TabCount = cPages.Count Then BtnAdd.Enabled = False End Sub End Class
Comment
-
Thanks you so where and how do I place this code? Thanks
Originally posted by SammyBOh bother, I forgot that Bill made it next to impossible -- you have to remove/add it to the TabPage's Controls collection. Here's the code for a form with a single TabPage, TabPage1 (mine had 3 tabs) and a button BtnAdd:
Code:Public Class Form1 Private cPages As New List(Of TabPage)() Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load ' Save each tab in cPages For i As Integer = 0 To TabControl1.TabCount - 1 cPages.Add(TabControl1.TabPages(i)) 'Save the tab Next i ' Remove all but First to make them invisible For i As Integer = TabControl1.TabCount - 1 To 1 Step -1 TabControl1.Controls.RemoveAt(i) Next i End Sub Private Sub BtnAdd_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles BtnAdd.Click TabControl1.Controls.Add(cPages(TabControl1.TabCount)) If TabControl1.TabCount = cPages.Count Then BtnAdd.Enabled = False End Sub End Class
Comment
-
HI,
Sammy,
I got most of everything figured out. I used the following code to add up the checkboxes but it is not adding it up for some reason. I tested it with 4 checkboxes and its fine. Any advice?
Code:Private Sub A1_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles A9.CheckedChanged, A8.CheckedChanged, A7.CheckedChanged, A6.CheckedChanged, A5.CheckedChanged, A48.CheckedChanged, A47.CheckedChanged, A46.CheckedChanged, A45.CheckedChanged, A44.CheckedChanged, A43.CheckedChanged, A42.CheckedChanged, A41.CheckedChanged, A40.CheckedChanged, A4.CheckedChanged, A39.CheckedChanged, A38.CheckedChanged, A37.CheckedChanged, A36.CheckedChanged, A35.CheckedChanged, A34.CheckedChanged, A33.CheckedChanged, A32.CheckedChanged, A31.CheckedChanged, A30.CheckedChanged, A3.CheckedChanged, A29.CheckedChanged, A28.CheckedChanged, A27.CheckedChanged, A26.CheckedChanged, A25.CheckedChanged, A24.CheckedChanged, A23.CheckedChanged, A22.CheckedChanged, A21.CheckedChanged, A20.CheckedChanged, A2.CheckedChanged, A19.CheckedChanged, A18.CheckedChanged, A17.CheckedChanged, A16.CheckedChanged, A15.CheckedChanged, A14.CheckedChanged, A13.CheckedChanged, A12.CheckedChanged, A11.CheckedChanged, A10.CheckedChanged, A1.CheckedChanged Dim s1 As Integer = 0 For Each c As Control In Me.Controls If TypeOf c Is CheckBox Then Dim chk As CheckBox = c If chk.Checked Then If chk.Name.StartsWith("A") Then s1 += chk.Tag End If End If End If Next c TextBox1.Text = s1.ToString() End Sub
Comment
-
Originally posted by jpmcafeeHI,
Sammy,
I got most of everything figured out. I used the following code to add up the checkboxes but it is not adding it up for some reason. I tested it with 4 checkboxes and its fine. Any advice?
For Each c As Control in TabPage1.Contro ls
but since these pages are in cPages, you just need to do:
Code:For Each c As Control In cPages(0).Controls
Comment
-
Ok,
Now I am at a point to make a results page. What I have is 11 tabbed pages on these tabbed pages I have 3 text boxes with a series of check boxes.
Now the sum of these check boxes is put into one text box. The other two textboxes provides for a name and position. What I need on this results page is to diplay in order by the highest sum the name, position and score they recieved. Now the trick is there are 11 tabbed pages sometimes all of them will be used and sometime not.
What I did so far is to create 11 text boxes on a new tabbed page (labled results) this wil provide room for the Name; then i made another colume of 11 for the position and another 11 for the score.
Does this seem like I am on the right trail?
Now where I could use help is to recognize which tab pages have results to pull in to the results page, and have it display the corresponding name and position to that score in a numerical order by highest to lowest score.
Thanks Guys,Comment
-
Originally posted by jpmcafeeOk,
Now I am at a point to make a results page. What I have is 11 tabbed pages on these tabbed pages I have 3 text boxes with a series of check boxes.
Now the sum of these check boxes is put into one text box. The other two textboxes provides for a name and position. What I need on this results page is to diplay in order by the highest sum the name, position and score they recieved. Now the trick is there are 11 tabbed pages sometimes all of them will be used and sometime not.
What I did so far is to create 11 text boxes on a new tabbed page (labled results) this wil provide room for the Name; then i made another colume of 11 for the position and another 11 for the score.
Does this seem like I am on the right trail?
Now where I could use help is to recognize which tab pages have results to pull in to the results page, and have it display the corresponding name and position to that score in a numerical order by highest to lowest score.
Thanks Guys,
Code:Private Sub A1_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles A9.CheckedChanged, and all the rest :D Dim s1 As Integer = 0 For Each c As Control In cPages(0).Controls If TypeOf c Is CheckBox Then Dim chk As CheckBox = c If chk.Checked Then If chk.Name.StartsWith("A") Then s1 += chk.Tag End If End If End If Next c TxtTotal1.Text = s1.ToString() TxtSummaryTotal1.Text = s1.ToString() TxtSummaryName1.Text = TxtName1.Text End Sub
Comment
-
Originally posted by SammyBYou doing great! For now, I would just keep it simple and whatever you change in the CheckedChange event also change on the summary page. Something like:
Code:Private Sub A1_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles A9.CheckedChanged, and all the rest :D Dim s1 As Integer = 0 For Each c As Control In cPages(0).Controls If TypeOf c Is CheckBox Then Dim chk As CheckBox = c If chk.Checked Then If chk.Name.StartsWith("A") Then s1 += chk.Tag End If End If End If Next c TxtTotal1.Text = s1.ToString() TxtSummaryTotal1.Text = s1.ToString() TxtSummaryName1.Text = TxtName1.Text End Sub
Sammy,
That looks good, however it looks like its just adding up all the checkboxes and displaying it on one page. I was actually thinking of like a multi dimensional array or somthing. Becuase I need it to
Each tabbed page diplays a Name.Box, PositionBox, and a Result Box.
the result box is the sum of checkboxes for that tabbed page remember.
What I need is for the summary page to recognize and sort by the highest sum.
Display those results with the following information from each tabbed page(again in order by the sum, Highest to lowest).
Name - Postion- Score(result)
Just to show you what I did ( I created a Results tab in a tool strip to show the results page)
The I did this
Code:Private Sub ToolStripButton2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ToolStripButton2.Click Dim addresultstab As Boolean For i As Integer = 0 To TabControl1.TabCount - 1 If TabControl1.TabPages(i).Text = "Results" Then addresultstab = False Exit For Else addresultstab = True End If Next i If addresultstab = True Then TabControl1.Controls.Add(cPages(11)) End If 'add results to results tab rtbResults.Text = "Employee Information Results" & vbCrLf rtbResults.Text = rtbResults.Text & "--------------------------------" & vbCrLf rtbResults.Text = rtbResults.Text & vbCrLf If NameBox1.Text <> "" Then rtbResults.Text = rtbResults.Text & NameBox1.Text & " (" & PoBox1.Text & "): " & ResultsBox1.Text & vbCrLf End If If NameBox2.Text <> "" Then rtbResults.Text = rtbResults.Text & NameBox2.Text & " (" & PoBox2.Text & "): " & ResultsBox2.Text & vbCrLf End If If NameBox3.Text <> "" Then rtbResults.Text = rtbResults.Text & NameBox3.Text & " (" & PoBox3.Text & "): " & ResultsBox3.Text & vbCrLf End If End Sub
Comment
Comment