Hello cascomp,
Currently, I agree with Justin. You can change the cell background color when you add a item.
I tried to accomplish your goal by myself, here is the result. I hope it can give you some ideas about your problem.
If you have any suggestions or ideas, please feel free to tell me.
Best Regards,
Greg Gu
Code:
#Generated Form Function
function GenerateForm {
########################################################################
# Code Generated By: SAPIEN Technologies PrimalForms (Community Edition) v1.0.10.0
# Generated On: 12/23/2011 9:44 AM
########################################################################
#region Import the Assemblies
[reflection.assembly]::loadwithpartialname("System.Windows.Forms") | Out-Null
[reflection.assembly]::loadwithpartialname("System.Drawing") | Out-Null
#endregion
#region Generated Form Objects
$form1 = New-Object System.Windows.Forms.Form
$textBox1 = New-Object System.Windows.Forms.TextBox
$button1 = New-Object System.Windows.Forms.Button
$dataGridView1 = New-Object System.Windows.Forms.DataGridView
$InitialFormWindowState = New-Object System.Windows.Forms.FormWindowState
#endregion Generated Form Objects
#----------------------------------------------
#Generated Event Script Blocks
#----------------------------------------------
#Provide Custom Code for events specified in PrimalForms.
$button1_OnClick=
{
$newData = $textBox1.Text
$rowIndex = $dataGridView1.Rows.Add($newData)
$dataGridView1.Rows.Item($rowIndex - 1).DefaultCellStyle.BackColor = "White"
$dataGridView1.Rows.Item($rowIndex).DefaultCellStyle.BackColor = "LightGreen"
$dataGridView1.FirstDisplayedScrollingRowIndex = $rowIndex
}
$handler_textBox1_TextChanged=
{
#TODO: Place custom script here
}
$handler_form1_Load=
{
$data = "blahblahblah"
$dataGridView1.Columns.Add("ColumnA","Column A")
$dataGridView1.Columns.Add("ColumnB","Column B")
$dataGridView1.ReadOnly = $true
$dataGridView1.MultiSelect = $false
$dataGridView1.Rows.Add($data)
$dataGridView1.Rows.Item(0).Selected = $false
}
$OnLoadForm_StateCorrection=
{#Correct the initial state of the form to prevent the .Net maximized form issue
$form1.WindowState = $InitialFormWindowState
}
#----------------------------------------------
#region Generated Form Code
$System_Drawing_Size = New-Object System.Drawing.Size
$System_Drawing_Size.Height = 262
$System_Drawing_Size.Width = 284
$form1.ClientSize = $System_Drawing_Size
$form1.DataBindings.DefaultDataSourceUpdateMode = 0
$form1.Name = "form1"
$form1.Text = "Primal Form"
$form1.add_Load($handler_form1_Load)
$textBox1.DataBindings.DefaultDataSourceUpdateMode = 0
$System_Drawing_Point = New-Object System.Drawing.Point
$System_Drawing_Point.X = 13
$System_Drawing_Point.Y = 198
$textBox1.Location = $System_Drawing_Point
$textBox1.Name = "textBox1"
$System_Drawing_Size = New-Object System.Drawing.Size
$System_Drawing_Size.Height = 20
$System_Drawing_Size.Width = 259
$textBox1.Size = $System_Drawing_Size
$textBox1.TabIndex = 2
$textBox1.add_TextChanged($handler_textBox1_TextChanged)
$form1.Controls.Add($textBox1)
$button1.DataBindings.DefaultDataSourceUpdateMode = 0
$System_Drawing_Point = New-Object System.Drawing.Point
$System_Drawing_Point.X = 13
$System_Drawing_Point.Y = 227
$button1.Location = $System_Drawing_Point
$button1.Name = "button1"
$System_Drawing_Size = New-Object System.Drawing.Size
$System_Drawing_Size.Height = 23
$System_Drawing_Size.Width = 259
$button1.Size = $System_Drawing_Size
$button1.TabIndex = 1
$button1.Text = "Add"
$button1.UseVisualStyleBackColor = $True
$button1.add_Click($button1_OnClick)
$form1.Controls.Add($button1)
$dataGridView1.DataBindings.DefaultDataSourceUpdateMode = 0
$System_Drawing_Point = New-Object System.Drawing.Point
$System_Drawing_Point.X = 12
$System_Drawing_Point.Y = 12
$dataGridView1.Location = $System_Drawing_Point
$dataGridView1.Name = "dataGridView1"
$System_Drawing_Size = New-Object System.Drawing.Size
$System_Drawing_Size.Height = 170
$System_Drawing_Size.Width = 260
$dataGridView1.Size = $System_Drawing_Size
$dataGridView1.TabIndex = 0
$form1.Controls.Add($dataGridView1)
#endregion Generated Form Code
#Save the initial state of the form
$InitialFormWindowState = $form1.WindowState
#Init the OnLoad event to correct the initial state of the form
$form1.add_Load($OnLoadForm_StateCorrection)
#Show the Form
$form1.ShowDialog()| Out-Null
} #End Function
#Call the Function
GenerateForm
Test result: