Comparison of cells in DataGrid

xiaoxiao2021-03-06  99

[Sharing] Comparison of cells in DataGrid

It took nearly half an hour to test it.

It is also a DataRow in the ASP.NET in ASP.NET.

I can't find it.

Later I saw there is a DataGridItemcollection and DataGridItem

The latter prompts to DataGrid items (line).

So this sentence:

INT i = dgcourse.Items.count; // DGCours is a DataGrid instance

Returns the value of i as a specific line, Well, finally found it.

But what should I do if the columns in the row do?

Remember Datacolumn

There is a DataGrid.columns in DataGrid

But that is only for all columns, and cannot perform a single row comparison.

So I am looking for DataGrid.Itemm.

Found there is a DataGrid.Item.cells of Dongdong, prompting "DataGrid item cell"

Well. It should be it, take two index and convert the string into int to compare

INT coursecount = 0;

INT coursepeo = 0;

Foreach (DataGridItem di in dgcourse.Items) // DataGridItem represents the line in DataGrid

{

Coursecount = int.parse (Di.cells [5] .text); // DataGridItem.cells [5] represents the sixth cell in the line

Coursepeo = int.parse (di.cells [6] .text);

IF (coursecount <= courtepeo) // cell comparison

{

Di.cells [6] .forecolor = system.drawing.color.red; // If it is not more than display red

}

}

转载请注明原文地址:https://www.9cbs.com/read-100059.html

New Post(0)