Solved

Sample Visual Studio C# Code

Posted on 2011-03-04
7
612 Views
Last Modified: 2013-12-17
Hello Community,

I am a beginner in C#. I would like to create a program that can do something like I am about to describe below:

4 Check boxes: A, B and C, D
2 list boxes: list box E (e1, e2, e3) and list box F(f1, f2, f3)
2 or more groups of random words for example group 1 would have dog, cat, bird and group 2 would have fish, lizard, turtle.
1 text box

If a user checks A plus C and chooses lets say e1 and f1, the program will pick a random word for one of the groups of random words and will display the word inside the text box.
0
Comment
Question by:petaganayr
  • 3
  • 3
7 Comments
 
LVL 85

Expert Comment

by:Mike Tomlinson
ID: 35041801
I don't see how the checkboxes and listboxes should be affecting the random choice from the groups of words.  Can you explain in more detail?...possibly with an example?
0
 
LVL 2

Author Comment

by:petaganayr
ID: 35042037
ok...mm..let me see...

first set of check boxes: I am a Male |  Female.
second set of check boxes: you're a Male |  Female.

first list box: I am a turtle, tiger, fish
second list box: you're a lion, eagle, frog

First group of random words: bite, swim, crawl
Second group of random words: fly, run, glide

So if a user picks, male on the first set of check boxes and female on the second set of check boxes, tiger on the first list box and lion on second the code will pick a random word from the first group of words.
0
 
LVL 9

Expert Comment

by:gery128
ID: 35043494
But what will be the logic for choosing group of random words?  on selecting one check-box of first checkbox list-1 and from checkbox list-2 there should be some condition for combinations and permutations of all checkbox lists and list boxes.

0
Webinar: Aligning, Automating, Winning

Join Dan Russo, Senior Manager of Operations Intelligence, for an in-depth discussion on how Dealertrack, leading provider of integrated digital solutions for the automotive industry, transformed their DevOps processes to increase collaboration and move with greater velocity.

 
LVL 85

Expert Comment

by:Mike Tomlinson
ID: 35043595
Yeah...I still don't see how the selections affect the random portion.  Do you simply want to combine what has been selected in the first set of controls with a random word from the first group?...and a random word from the second group to go along with the second set of controls?

Male, Tiger, {Random word from: bite, swim, crawl}
Female, Lion, {Random word from: fly, run, glide}
0
 
LVL 2

Author Comment

by:petaganayr
ID: 35044271
There is no logic, I just want to find out if it possible to do.

Okay, here's another try

Male - Tiger | Female - Lion  | bite
I would like to tell it to go and get me a random word from group 1 and show it in a textbox.

Female - Turtle | Male - Frog | fly
Go get me a random word from group 2 and show it in a textbox.

To gery128 - 'condition for combinations and permutations of all checkboxes and list boxes'
Thats what I am trying to do or figure out. What would a sample code look like for something like that? And if I am going to search for something like in MSDN, would it be called combinations and permutations statement?

Thanks!
0
 
LVL 85

Accepted Solution

by:
Mike Tomlinson earned 500 total points
ID: 35044489
Maybe this will get you started:
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;

namespace WindowsFormsApplication1
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }

        private Random R = new Random();
        private List<string> Group1 = new List<string>();
        private List<string> Group2 = new List<string>();

        private void Form1_Load(object sender, EventArgs e)
        {
            Group1.Add("bite");
            Group1.Add("swim");
            Group1.Add("crawl");

            Group2.Add("fly");
            Group2.Add("run");
            Group2.Add("glide");
        }

        private void button1_Click(object sender, EventArgs e)
        {
            textBox1.Text = Group2[R.Next(0, Group2.Count)];
        }

        private void button2_Click(object sender, EventArgs e)
        {
            textBox2.Text = Group2[R.Next(0, Group2.Count)];
        }

    }
}

Open in new window

Idle-Mind-416703.flv
0
 
LVL 2

Author Closing Comment

by:petaganayr
ID: 35176353
Thank you for the visual aid Idle-Mind.
0

Featured Post

DevOps Toolchain Recommendations

Read this Gartner Research Note and discover how your IT organization can automate and optimize DevOps processes using a toolchain architecture.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

In my previous two articles we discussed Binary Serialization (http://www.experts-exchange.com/A_4362.html) and XML Serialization (http://www.experts-exchange.com/A_4425.html). In this article we will try to know more about SOAP (Simple Object Acces…
A long time ago (May 2011), I have written an article showing you how to create a DLL using Visual Studio 2005 to be hosted in SQL Server 2005. That was valid at that time and it is still valid if you are still using these versions. You can still re…
This video shows how to use Hyena, from SystemTools Software, to bulk import 100 user accounts from an external text file. View in 1080p for best video quality.

809 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question