Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

Sample Visual Studio C# Code

Posted on 2011-03-04
7
Medium Priority
?
621 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
What is SQL Server and how does it work?

The purpose of this paper is to provide you background on SQL Server. It’s your self-study guide for learning fundamentals. It includes both the history of SQL and its technical basics. Concepts and definitions will form the solid foundation of your future DBA expertise.

 
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

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Entity Framework is a powerful tool to help you interact with the DataBase but still doesn't help much when we have a Stored Procedure that returns more than one resultset. The solution takes some of out-of-the-box thinking; read on!
The article shows the basic steps of integrating an HTML theme template into an ASP.NET MVC project
Have you created a query with information for a calendar? ... and then, abra-cadabra, the calendar is done?! I am going to show you how to make that happen. Visualize your data!  ... really see it To use the code to create a calendar from a q…
We’ve all felt that sense of false security before—locking down external access to a database or component and feeling like we’ve done all we need to do to secure company data. But that feeling is fleeting. Attacks these days can happen in many w…

598 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