Change background color and item text in GridView [closed]

0

I have GridView with multiple numbers and I have a click event on items from this GridView . I would like the items that have already been clicked to change the background and text colors, to show the user that they have already been clicked. If possible disable for future clicks.

The event is this:

private void dataGridNumbers_Tapped(object sender, TappedRoutedEventArgs e)
{
    string selectedNumber = dataGridNumbers.SelectedItem.ToString();

    if (selectedNumber == resposta)
    {
        txtBoxInfo.Text = "Congratulations! You Find the Ramdon Number!";
    }
    if (selectedNumber != resposta)
    {
        numbersCloser(Int32.Parse(selectedNumber));
    }
}
    
asked by anonymous 05.07.2017 / 06:13

1 answer

1

Use event dataGridNumbers_CellClick

private void dataGridNumbers_CellClick(object sender, DataGridViewCellEventArgs e)
{
    dataGridView1.Rows[e.RowIndex].DefaultCellStyle.BackColor = Color.DarkGreen;
    dataGridView1.Rows[e.RowIndex].DefaultCellStyle.ForeColor = Color.Red;
    dataGridView1.Rows[e.RowIndex].ReadOnly = true;
}

UWP

GridView.Background = new SolidColorBrush(Windows.UI.Colors.Red);
    
06.07.2017 / 22:37