There are many ways to learn to code these days. From coding bootcamps like Flatiron School to online courses to totally free beginner resources. The best way to learn to code depends on many factors, but the most important one is you. See what course is best for you.
Anyway to create this example drop a string grid on your form. Create a method to initilize the string grid. And create a OnDrawCell event code handler for your String grid. This example simply puts 10 random numbers in column 2 and then sets the background color to red if the number is <= 5.
Again let me know if you need help converting to delphi. Maybe sombody can tell me how to tell from a post what language they are using java, c++, c#, Delphi, etc.
__fastcall TForm1::TForm1(TComponent*
: TForm(Owner)
{
InitializeStringGrid();
}
//------------------------
void __fastcall TForm1::InitializeStringGr
{
StringGrid1->FixedCols = 2;
StringGrid1->ColCount = 2;
StringGrid1->Cells[0][0] = "ID";
StringGrid1->Cells[1][0] = "Random Num";
//fill the string grid with 10 random numbers
//the random numbers will be stored in the second column
StringGrid1->RowCount = 11;
for(int i = 0; i < 10; i ++)
{
StringGrid1->Cells[0][i+1]
StringGrid1->Cells[1][i+1]
}
}
void __fastcall TForm1::StringGrid1DrawCel
int ARow, TRect &Rect, TGridDrawState State)
{
//were only intersted in making the cell red if the number is less than
//or equal to 5. Since the id's are stored in col one they are of no interest
if(ACol != 1)
return;
//not interested in first row
if(ARow == 0)
return;
int value = StrToInt(StringGrid1->Cell
if(value <= 5)
{
//make the cell red
StringGrid1->Canvas->Brush
StringGrid1->Canvas->FillR
//since we just drew over the entire cell we need to redraw our string on top of the red
StringGrid1->Canvas->Pen->
StringGrid1->Canvas->TextO
}
}