I need your help once more. My if/else statment isn't working at all. I tried to do everything and look up at the code for the errors and didn't find any errors, or maybe I couldn't see any errors on it.

I used in VEntradas Form:

private string entrada;

public string entradas {
     get { return entrada; }
     set { entrada = value; }
}

I used this so I can pick the value from workgroup textbox that is at Form1.

Also in VEntradas Form I put the following:

if (entrada == "Marketing")
{

    nDoc.Visible = false;
    button1.Visible = false;
    label1.Text = "Não tens acesso à edição de entradas.";
}
else 
{
    nDoc.Visible = true;
    button1.Visible = true;
    nDoc.Enabled = true;
    button1.Enabled = true;
    label1.Text = "";
} 

Even with this, the if/else statment isn't working and in "Marketing" value of workgroup textbox (Form1) it appears the buttons and shouldn't appear... Anyone can help me with it?

When I run this inside at the form itself VEntradas it only runs the if statment and it runs for both of values "Marketing" and "Wharehouse" and I want to make it work only for "Marketing" the if statment while the else stament is for "Wharehouse"

entrada is a private string, returned by the public property entradas
if (entradas == "Marketing") instead of if (entrada == "Marketing") ?

ddanbe I tried out that and still keeps doing the same thing...
I let here the whole code of VEntradas Form:

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace Storage
{
    public partial class VEntradas : Form
    {

        private string entrada;

        public string entradas
        {
            get { return entrada; }
            set { entrada = value; }
        } 

        public VEntradas()
        {
            InitializeComponent();
        }

        private void VEntradas_Load(object sender, EventArgs e)
        {
            // TODO: This line of code loads data into the 'storageBDDataSet.Entradas' table. You can move, or remove it, as needed.
            this.entradasTableAdapter.Fill(this.storageBDDataSet.Entradas);
            Home.okLogin = true;
            panel1.Dock = DockStyle.Top;
            nDoc.Cursor = Cursors.Hand;
            button1.Cursor = Cursors.Hand;
            Home frn = new Home();
            entradasDataGridView.Dock = DockStyle.Fill;
            if (entradas == "Armazem")
            {

                this.nDoc.Visible = true;
                this.button1.Visible = true;
                this.label1.Text = "";

            }
            else 
            {

                // nDoc.Enabled = false;
                // button1.Enabled = false;
                this.nDoc.Visible = false;
                this.button1.Visible = false;
                this.label1.Text = "Tu não tens acesso à edição de entradas.";      
            }
           /* else
            {
                // nDoc.Enabled = false;
                // button1.Enabled = false;
                nDoc.Visible = false;
                button1.Visible = false;
                label1.Text = "Tu não tens acesso a edição de entradas.";
            } */
        }

        private void button1_MouseHover(object sender, EventArgs e)
        {
            label1.Text = "Editar Entradas";
        }

        private void button1_MouseLeave(object sender, EventArgs e)
        {
            label1.Text = "";
        }

        private void nDoc_MouseHover(object sender, EventArgs e)
        {
            label1.Text = "Nova Entrada";
        }

        private void nDoc_MouseLeave(object sender, EventArgs e)
        {
            label1.Text = "";
        }

        private void entradasBindingNavigatorSaveItem_Click(object sender, EventArgs e)
        {
            this.Validate();
            this.entradasBindingSource.EndEdit();
            this.tableAdapterManager.UpdateAll(this.storageBDDataSet);

        }
    }
}

You nevre seem to be setting the property entradas to something (Did the compiler not gave you a warning?) so it is hard for the if statement to figure it out. Give it an initial value in your constructor or somewhere else.

No, no warnings about. That is the most awkward thing I see... I was looking always on that and no warnings.... I can't find where the problem is... ddanbe

Did you debug and saw what value entradas had before starting with the if?

Yes, I saw. And it was the same value that I put on the if...

And did you step through your code to see wath happend in the if else?

Didn't go further than Home Form it was stuck and repeating the same thing all the time.

So the problem seems not to be the if then? Yes?
What do you mean by Home Form?

Well I tried now and went to that part, but didn't show anything about the if or else statment

So the problem seems not to be the if then? Yes?
Could you please be more specific?
I went to that part?? You see that part, I don't.

this part:

if (entradas == "Armazem")
            {
                this.nDoc.Visible = true;
                this.button1.Visible = true;
                this.label1.Text = "";
            }
            else 
            {
                // nDoc.Enabled = false;
                // button1.Enabled = false;
                this.nDoc.Visible = false;
                this.button1.Visible = false;
                this.label1.Text = "Tu não tens acesso à edição de entradas.";      
            }

at debbugging and still no results

What do you mean by no results?
What error messages do you get?
What is happening?
Where is the debugger stepping in?
etc.
no results gives me no information to help solve your problem.
As I said before, please be more specific. I cannot look over your shoulder you know.

Doesn't appear any error or nothing... It doesn't show nothing... And a friend of mine saw as well...

I don't know what it is happening... I'm doing with myself crazy if this continues like this...

Please post your code for "Form1.cs". It looks like it should contain an instance of "VEntradas" and something that sets the value of "entradas" for the instance.

example code in Form1.cs:

VEntradas myVEntradas = new VEntradas();

myVEntradas.entradas = "Armazem";

myVentradas.ShowDialog();

Also, if you aren't going to set an initial value for "entrada", you don't need to do the following:

private string entrada;

public string entradas
{
    get { return entrada; }
    set { entrada = value; }
} 

You can just do the following:

public string entradas { get; set; }

Also, you have:

Home.okLogin = true;

        ...

Home frn = new Home();

which should probably be:

Home frn = new Home();

        ...

Home.okLogin = true;

even if "okLogin" is defined as static--it makes your code easier to follow.

"ContextMenuStrip" may be of use in your program as well.

Thanks cgeier!

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.