Pick up records on Datagridview and play on a label

Asked

Viewed 402 times

1

Guys, my idea is this, I want to pick up records on a Datagridview and play on five Abels. Each one corresponds to a command, and these boxes will change to another record once clicked.

Example:

  1. Label1.Text = "Você gosta de programar?"; (The question label will have no action, only be changed by clicking on one of the others)
  2. Label2.Text = "Gosto"; (This label will receive actions to add five points to users, it will change the text of all Abels.)
  3. Label3.Text = "Mais ou menos"; (This label will do the same as the label2.)

With the click of the user, the Abels would pick up the next user record until all records were gone.

I tried to put a while with a variable counting lines, but the label does not change its text.

This is my current code:

label1.Text = questoesTableAdapter.ConsultaPergunta(1);

int numero_Linhas = dataGridView1.RowCount;
int i =1;
while (i < numero_Linhas)
{
    label1.Text = questoesTableAdapter.ConsultaPergunta(i);
    label2.Text = i.ToString();

    ++i;
}

I’m only using two label’s for testing, one gets the counter, and the other the text of the question.

My table is as follows:

inserir a descrição da imagem aqui

  • 1

    The problem is that the label1 does not show the data you need? If yes, this should be a problem within the method questoesTableAdapter.ConsultaPergunta(i);, Have you made sure that it returns the data correctly? I still can’t understand the purpose of the while - it will change the text of label at each run, this seems wrong. Do you have how to [Edit] your question and add more details? Both the code of the methods you use and how the app should work.

  • your title is ... Pick up records on SQL Server 2014 and play on a label ...and on the description ...I want to pick up records on a Datagridview and play on five Abels ... a little confusing ..

  • First of all, I apologize to you for the lack of information in my question. I’m still getting the hang of this thing of asking for help in forums... Well, the idea is to count the total of columns in Datagridview, as soon as you count, to do a while with this total. Inside "while", I want to have five Labels having text changes (text leaves the table in Datagridview) as soon as any of them are clicked. For example: label_question.Text = "What is your name?" ; label_resposta1.Text = "Gian"; label_resposta2.Text = "Bueno"; label_resposta3.Text = "Marconcilio"; label_resposta4.Text = "Lucas";

  • Gian, check your comment above. Can you understand the code right? No, right? So, pro tip: when you have questions edit your question and give a touch through a comment @fulano, editei a pergunta e tal e tal.

No answers

Browser other questions tagged

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