Solved

Sample Visual Studio C# Code

Posted on 2011-03-04
7
609 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
DevOps Toolchain Recommendations

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

 
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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Performance in games development is paramount: every microsecond counts to be able to do everything in less than 33ms (aiming at 16ms). C# foreach statement is one of the worst performance killers, and here I explain why.
This article aims to explain the working of CircularLogArchiver. This tool was designed to solve the buildup of log file in cases where systems do not support circular logging or where circular logging is not enabled
Along with being a a promotional video for my three-day Annielytics Dashboard Seminor, this Micro Tutorial is an intro to Google Analytics API data.
Sending a Secure fax is easy with eFax Corporate (http://www.enterprise.efax.com). First, just open a new email message. In the To field, type your recipient's fax number @efaxsend.com. You can even send a secure international fax — just include t…

863 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

Need Help in Real-Time?

Connect with top rated Experts

26 Experts available now in Live!

Get 1:1 Help Now