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
– Ricardo Pontual
How to get the Checkbook value for access
– Alberto Mamona Betilson
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– Ricardo Pontual
is like this bool state = Convert.Toboolean(data["Closed"]);
– Alberto Mamona Betilson
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 thischeckBox1.Checked = estado
?– Ricardo Pontual
OK idea if it is marked in the comic the question will not appear during the game for using the if
– Alberto Mamona Betilson
Okay, I guess it’s then if I reverse the
estado = checkBox1.Checked;
forcheckBox1.Checked= estado
:)– Ricardo Pontual
ok I’ll try to do this way
– Alberto Mamona Betilson
Did not work this way checkBox1.Checked= status
– Alberto Mamona Betilson