use yes in access and c# using checkbox in c# greenmark or false

Asked

Viewed 25 times

0

I am creating a quiz and the questions are repeating. I intend to use the checkbox when checking whether or not the same checkbox has been used.

I’m using the following code:

            int[] num = new int[13];
            System.Random aleat = new System.Random();
            int valomaximo = 12;
            int valorminimo = 1;
            int varial = aleat.Next(valorminimo, valomaximo);
            varial = aleat.Next(valorminimo, valomaximo) + 1;

            OleDbConnection conexao = new OleDbConnection();
            OleDbCommand consuta = new OleDbCommand();
            OleDbDataReader Leitor;
            conexao.ConnectionString = Angola.BUscar_Caminho();
            conexao.Open();
            consuta.CommandText = "SELECT *FROM Perguntas  where NumeroDeOrdem = " + varial + " AND Nivel = " + textoNivelFinal.Text + " ";
            consuta.CommandType = CommandType.Text;
            consuta.Connection = conexao;
            Leitor = consuta.ExecuteReader();
            DataTable tepergunta = new DataTable();
            tepergunta.Load(Leitor);

            foreach (DataRow data in tepergunta.Rows)
            {
                string Pergunta = data["Perguntas"].ToString();
                // btperguta.Text = (Leitor["Perguntas"].ToString());
                string A = data["A"].ToString();
                string B = data["B"].ToString();
                string C = data["C"].ToString();
                string D = data["D"].ToString();
                string RC = data["Respostascertas"].ToString();
                bool estado = Convert.ToBoolean(data["Fechada"]);
                btperguta.Text = Pergunta;
                btrespa.Text = A;
                btrespb.Text = B;
                btrespc.Text = C;
                btrespd.Text = D;
                label1.Text = RC;
                checkBox1.Checked= estado;
                checkBox1.Text = varial.ToString();
                checkBox1.Checked = true;

                data["Fechada"] = checkBox1.Checked;
                checkBox1.Checked = true;
                
                estado = checkBox1.Checked;

                if (checkBox1.Checked==true)
                {
                    estado = true;
                    data["Fechada"] = checkBox1.Checked;
                    checkBox1.Checked = true;
                }
                else 
                {
                    estado = false;
                }
  • and what is your doubt? it was not clear

  • How to get the Checkbook value for access

  • data["nome-do-campo"] now how to convert depends on the type of data that is in the table. Usually converts to bool if the field is to type yes/no

  • is like this bool state = Convert.Toboolean(data["Closed"]);

  • then I don’t understand why estado = checkBox1.Checked;, this will overwrite the value of the bank, and tbm the following does not make sense, would not suffice to put the value of the bank in the checkbox? something like this checkBox1.Checked = estado?

  • OK idea if it is marked in the comic the question will not appear during the game for using the if

  • Okay, I guess it’s then if I reverse the estado = checkBox1.Checked; for checkBox1.Checked= estado :)

  • ok I’ll try to do this way

  • Did not work this way checkBox1.Checked= status

Show 4 more comments
No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.