Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C#
  4. backcolor in load form

backcolor in load form

Scheduled Pinned Locked Moved C#
questiondatabasedebugginghelp
3 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • F Offline
    F Offline
    faladrim
    wrote on last edited by
    #1

    hi, i want to change the color of rows with wrong info when i load my form, the info comes from a database, it is checked on error earlier and replaced the value of the cell with "wrong info", now in my load i check all the cells of my datagrid on "wrong info" values if ther is one i want that entire row to color red. i have tried it for one column where there is wrong info, the breakpoint shows me that he does the color changing, but nothing has changed in the view. is it changed back so quickly that i couldnt see it in red? if yes , where woud that code be written? in the defaultview maybe? and how do i sort it then? this is what i wrote in the load from function: lastrow = dataGridView1.Rows.GetLastRow(DataGridViewElementStates.Visible); for (int x = 0; x < lastrow + 1; x++) { string fout = dataGridView1.Rows[x].Cells[3].Value.ToString(); if (fout == "wrong info")//check on wrong info { dataGridView1.Rows[x].Cells[3].Style.BackColor = Color.Red;// color red dataGridView1.Rows[x].Cells[3].Value = "error";// change value to error } } thx

    J 1 Reply Last reply
    0
    • F faladrim

      hi, i want to change the color of rows with wrong info when i load my form, the info comes from a database, it is checked on error earlier and replaced the value of the cell with "wrong info", now in my load i check all the cells of my datagrid on "wrong info" values if ther is one i want that entire row to color red. i have tried it for one column where there is wrong info, the breakpoint shows me that he does the color changing, but nothing has changed in the view. is it changed back so quickly that i couldnt see it in red? if yes , where woud that code be written? in the defaultview maybe? and how do i sort it then? this is what i wrote in the load from function: lastrow = dataGridView1.Rows.GetLastRow(DataGridViewElementStates.Visible); for (int x = 0; x < lastrow + 1; x++) { string fout = dataGridView1.Rows[x].Cells[3].Value.ToString(); if (fout == "wrong info")//check on wrong info { dataGridView1.Rows[x].Cells[3].Style.BackColor = Color.Red;// color red dataGridView1.Rows[x].Cells[3].Value = "error";// change value to error } } thx

      J Offline
      J Offline
      jeyapandian
      wrote on last edited by
      #2

      dataGridView1.Rows[x].Cells[3].Style.BackColor = Color.Red;// color red dataGridView1.Rows[x].DefaultCellStyle.BackColor = System.Drawing.Color.Red good luck

      Where there is a will,there is a way.

      F 1 Reply Last reply
      0
      • J jeyapandian

        dataGridView1.Rows[x].Cells[3].Style.BackColor = Color.Red;// color red dataGridView1.Rows[x].DefaultCellStyle.BackColor = System.Drawing.Color.Red good luck

        Where there is a will,there is a way.

        F Offline
        F Offline
        faladrim
        wrote on last edited by
        #3

        thx, i also found something in the meentime :) private void dataGridView1_RowsAdded(object sender, DataGridViewRowsAddedEventArgs e) { index = dataGridView1.Rows.GetLastRow(DataGridViewElementStates.Visible); for (int x = 0; x < index + 1; x++) { for (int y = 0; y < colamount; y++) { string fout = dataGridView1.Rows[x].Cells[y].Value.ToString(); if (fout == "foute input!") { dataGridView1.Rows[x].Cells[y].Style.BackColor = Color.Red; } } } } instead of using the load im using addrows, so i dont have to write this when the form loads and when im adding a row :) grz

        1 Reply Last reply
        0
        Reply
        • Reply as topic
        Log in to reply
        • Oldest to Newest
        • Newest to Oldest
        • Most Votes


        • Login

        • Don't have an account? Register

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • World
        • Users
        • Groups