Solved

Sample Visual Studio C# Code

Posted on 2011-03-04
7
607 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
How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

 
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

What Security Threats Are You Missing?

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

Join & Write a Comment

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…
Calculating holidays and working days is a function that is often needed yet it is not one found within the Framework. This article presents one approach to building a working-day calculator for use in .NET.
This demo shows you how to set up the containerized NetScaler CPX with NetScaler Management and Analytics System in a non-routable Mesos/Marathon environment for use with Micro-Services applications.
When you create an app prototype with Adobe XD, you can insert system screens -- sharing or Control Center, for example -- with just a few clicks. This video shows you how. You can take the full course on Experts Exchange at http://bit.ly/XDcourse.

760 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

21 Experts available now in Live!

Get 1:1 Help Now