Keep cell forecolor as original after selected of datadridview?


#1

Hi,
I am looking for a way to keep the cell forecolor as original after selected,I tried many ways but does not work,any help would be much thanks!

 try (destroydialog dgv_test) catch ()
rollout dgv_test "dgv_test"  width:600 height:400
(
	dotNetControl test_dgv "System.Windows.Forms.DataGridView" pos:[0,0] width:600 height:400	

	on dgv_test open do
	(		
		test_dgv.SelectionMode=(dotNetClass "System.Windows.Forms.DataGridViewSelectionMode").FullRowSelect	
		test_dgv.DefaultCellStyle.SelectionBackColor=(dotnetclass "system.drawing.color").fromARGB 232 236 200
		test_dgv.DefaultCellStyle.SelectionForeColor=(dotnetclass "system.drawing.color").fromARGB 106 106 106
	
		test_dgv.defaultCellStyle.backColor=(dotnetclass "system.drawing.color").fromARGB 238 241 245
		test_dgv.ForeColor=(dotnetclass "system.drawing.color").fromARGB 106 106 106
	
		test_01=dotNetObject "System.Windows.Forms.DataGridViewTextBoxColumn"
		test_01.width=200
	
		test_02=dotNetObject "System.Windows.Forms.DataGridViewTextBoxColumn"
		test_02.width=200
		
		test_dgv.columns.add test_01 
		test_dgv.columns.add test_02
		
		test_dgv.rows.add #("22222","4444444444")
		test_dgv.rows.add #("5555555555","77777")
	
		for i=1 to 2 do
		(
			test_dgv.rows.item[i-1].cells.item[0].Style.ForeColor=(dotnetclass "system.drawing.color").fromARGB 26 157 227
			test_dgv.rows.item[i-1].cells.item[1].Style.ForeColor=(dotnetclass "system.drawing.color").fromARGB 235 25 25
		)
		test_dgv.ClearSelection()
	)
	on test_dgv SelectionChanged sender e do
	(
		--how to keep the cells forecolor as original(red or blue) after the cells are selected?
	)
	
)
createdialog dgv_test

#2

use script below in SelectionChanged event

ssel=test_dgv.SelectedCells
for i = 0 to ssel.count - 1 do
ssel.item[i].Style.SelectionForeColor  = ssel.item[i].Style.ForeColor

#3

Works,perfect,too much thanks!