Click here to Skip to main content
15,885,653 members
Home / Discussions / C#
   

C#

 
AnswerRe: Is there a way to make "speakers" pickup 440hz? Pin
Frankie-C1-Mar-15 1:21
Frankie-C1-Mar-15 1:21 
AnswerRe: Is there a way to make "speakers" pickup 440hz? Pin
GrooverFromHolland1-Mar-15 1:25
GrooverFromHolland1-Mar-15 1:25 
QuestionIs there Any Way to Set the Namespace of a Web Service in Configuration instead of Code? Pin
jojoba2027-Feb-15 22:52
jojoba2027-Feb-15 22:52 
AnswerRe: Is there Any Way to Set the Namespace of a Web Service in Configuration instead of Code? Pin
Dave Kreskowiak28-Feb-15 4:08
mveDave Kreskowiak28-Feb-15 4:08 
AnswerRe: Is there Any Way to Set the Namespace of a Web Service in Configuration instead of Code? Pin
jojoba2028-Feb-15 22:35
jojoba2028-Feb-15 22:35 
QuestionDataGridView Entry Disappears (C#) Pin
Member 1148588827-Feb-15 8:53
Member 1148588827-Feb-15 8:53 
AnswerRe: DataGridView Entry Disappears (C#) Pin
Dave Kreskowiak27-Feb-15 11:26
mveDave Kreskowiak27-Feb-15 11:26 
GeneralRe: DataGridView Entry Disappears (C#) Pin
Member 1148588827-Feb-15 12:08
Member 1148588827-Feb-15 12:08 
Here is the code for the main page where the tab control is, with the four DGV's:
C#
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

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

        private void button1_Click(object sender, EventArgs e)
        {
            cover form1 = new cover();
            form1.Show();
            this.Hide();
        }

        private void button2_Click(object sender, EventArgs e)
        {
            additem form1 = new additem();
            form1.Show();
            this.Hide();
        }

        private void deletebutton_Click(object sender, EventArgs e)
        {
            DialogResult deleteitem = MessageBox.Show("Delete selected item?\t\t\t", "Delete Item", MessageBoxButtons.YesNo, MessageBoxIcon.Warning);

            if (deleteitem == DialogResult.Yes)
            {
                foreach (DataGridViewRow item in this.datagridview1.Rows)
                {
                    datagridview1.Rows.RemoveAt(item.Index);
                }
                foreach (DataGridViewRow item in this.datagridview2.Rows)
                {
                    datagridview2.Rows.RemoveAt(item.Index);
                }
                foreach (DataGridViewRow item in this.datagridview3.Rows)
                {
                    datagridview3.Rows.RemoveAt(item.Index);
                }
                foreach (DataGridViewRow item in this.datagridview4.Rows)
                {
                    datagridview4.Rows.RemoveAt(item.Index);
                }

                MessageBox.Show("Item deleted.\t\t\t", "Delete Item", MessageBoxButtons.OK, MessageBoxIcon.Information);

            }  

        }
    }
}


And here is the additem page, where after clicking add, the item and quantity should be added to the appropriate DGV after selecting a valid category:
C#
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace WindowsFormsApplication1
{
    public partial class additem : Form
    {
        public additem()
        {
            InitializeComponent();
            datetimelabel.Text = DateTime.Now.ToString("MM/dd/yyyy");
            this.quantitybox.KeyPress += new KeyPressEventHandler(quantitybox_KeyPress);
        }
        private void additem_Load(object sender, EventArgs e)
        {
             
        }

        private void button1_Click(object sender, EventArgs e)
        {
            invmain form1 = new invmain();
            form1.Show();
            this.Hide();
        }

        private void quantitybox_KeyPress(object sender, KeyPressEventArgs e)
        {
            e.Handled = !(char.IsDigit(e.KeyChar) || e.KeyChar == '\b'); 
        }

        private void add_Click(object sender, EventArgs e)
        {           
            //OBJECT REFERENCE TO DGV
            invmain invmainobject = new invmain();

            //SWITCH STATEMENT FOR DIRECTING USER-ENTERED INVENTORY DATA  
            //TO THE APPROPRIATE TABCONTROL TAB AND DGV

            switch(combobox1.SelectedIndex)
            {
                case 0: //ELECTRICAL
                    invmainobject.datagridview1.Rows.Add(itembox.Text, quantitybox.Text);
                    break;
                case 1: //MECHANICAL
                    invmainobject.datagridview2.Rows.Add(itembox.Text, quantitybox.Text);
                    break;
                case 2: //CABLES
                    invmainobject.datagridview3.Rows.Add(itembox.Text, quantitybox.Text);
                    break;
                case 3: //MISC.
                    invmainobject.datagridview4.Rows.Add(itembox.Text, quantitybox.Text);
                    break;
                default:
                    MessageBox.Show("Please select a category.\t\t", "Required Field Missing", MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
                    combobox1.Focus();
                    return;
            }

            if (string.IsNullOrWhiteSpace(this.itembox.Text))
            {
                MessageBox.Show("The 'Item' field is required.\t\t\t", "Required Field Missing", MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
                itembox.Focus();
                return;
            }

            if (string.IsNullOrWhiteSpace(this.quantitybox.Text))
            {
                MessageBox.Show("The 'Quantity' field is required.\t\t\t", "Required Field Missing", MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
                quantitybox.Focus();
                return;
            }

            invmainobject.Show();
            this.Close();
        }
        
        private void button1_Click_1(object sender, EventArgs e)
        {
            //ADD IMAGE OF ITEM (OPTIONAL)
            OpenFileDialog open = new OpenFileDialog();
            if (open.ShowDialog() == DialogResult.OK)
                uploadpic.Image = Bitmap.FromFile(open.FileName);
        }
    }
}


Note that I'm no longer using .ShowDialog(), because of the trouble of multiple forms I got.

modified 27-Feb-15 18:16pm.

GeneralRe: DataGridView Entry Disappears (C#) Pin
Dave Kreskowiak27-Feb-15 13:16
mveDave Kreskowiak27-Feb-15 13:16 
GeneralRe: DataGridView Entry Disappears (C#) Pin
Member 114858881-Mar-15 11:32
Member 114858881-Mar-15 11:32 
GeneralRe: DataGridView Entry Disappears (C#) Pin
Dave Kreskowiak1-Mar-15 12:43
mveDave Kreskowiak1-Mar-15 12:43 
GeneralRe: DataGridView Entry Disappears (C#) Pin
Member 114858881-Mar-15 13:45
Member 114858881-Mar-15 13:45 
GeneralRe: DataGridView Entry Disappears (C#) Pin
Dave Kreskowiak1-Mar-15 15:29
mveDave Kreskowiak1-Mar-15 15:29 
QuestionHow can I pass a Lync url from C sharp to Lync and launch the meeting? Pin
turbosupramk327-Feb-15 6:27
turbosupramk327-Feb-15 6:27 
AnswerRe: How can I pass a Lync url from C sharp to Lync and launch the meeting? Pin
Eddy Vluggen1-Mar-15 22:48
professionalEddy Vluggen1-Mar-15 22:48 
GeneralRe: How can I pass a Lync url from C sharp to Lync and launch the meeting? Pin
turbosupramk32-Mar-15 6:32
turbosupramk32-Mar-15 6:32 
GeneralRe: How can I pass a Lync url from C sharp to Lync and launch the meeting? Pin
Eddy Vluggen2-Mar-15 7:54
professionalEddy Vluggen2-Mar-15 7:54 
QuestionAudio Finger Print For Advertisements Provider (For Discussion) Pin
Max Bayne27-Feb-15 0:29
Max Bayne27-Feb-15 0:29 
AnswerRe: Audio Finger Print For Advertisements Provider (For Discussion) Pin
Pete O'Hanlon27-Feb-15 2:47
mvePete O'Hanlon27-Feb-15 2:47 
GeneralRe: Audio Finger Print For Advertisements Provider (For Discussion) Pin
Max Bayne27-Feb-15 21:35
Max Bayne27-Feb-15 21:35 
QuestionParse Stream by Pattern Pin
gpc4426-Feb-15 23:37
gpc4426-Feb-15 23:37 
AnswerRe: Parse Stream by Pattern Pin
OriginalGriff27-Feb-15 0:12
mveOriginalGriff27-Feb-15 0:12 
GeneralRe: Parse Stream by Pattern Pin
gpc4427-Feb-15 0:57
gpc4427-Feb-15 0:57 
GeneralRe: Parse Stream by Pattern Pin
OriginalGriff27-Feb-15 2:43
mveOriginalGriff27-Feb-15 2:43 
JokeRe: Parse Stream by Pattern Pin
Richard MacCutchan27-Feb-15 2:52
mveRichard MacCutchan27-Feb-15 2:52 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.