?
Solved

Sample Visual Studio C# Code

Posted on 2011-03-04
7
Medium Priority
?
618 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 3
7 Comments
 
LVL 86

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
Docker-Compose to Simplify Multi-Container Builds

Our veteran DevOps Author takes you through how to build a multi-container environment, managed with a single utility in order to simplify your deployments.

 
LVL 86

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 86

Accepted Solution

by:
Mike Tomlinson earned 2000 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

NEW Veeam Agent for Microsoft Windows

Backup and recover physical and cloud-based servers and workstations, as well as endpoint devices that belong to remote users. Avoid downtime and data loss quickly and easily for Windows-based physical or public cloud-based workloads!

Question has a verified solution.

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

Exception Handling is in the core of any application that is able to dignify its name. In this article, I'll guide you through the process of writing a DRY (Don't Repeat Yourself) Exception Handling mechanism, using Aspect Oriented Programming.
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.
Michael from AdRem Software explains how to view the most utilized and worst performing nodes in your network, by accessing the Top Charts view in NetCrunch network monitor (https://www.adremsoft.com/). Top Charts is a view in which you can set seve…
Add bar graphs to Access queries using Unicode block characters. Graphs appear on every record in the color you want. Give life to numbers. Hopes this gives you ideas on visualizing your data in new ways ~ Create a calculated field in a query: …
Suggested Courses

765 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