Guten Tag, ich zeige meine Abfragen von Tabelle in das Datagrid. Aber ich habe ein Problem mit meinen Codes. Ich habe versucht, in meinem dgview_CellFormatting zu debuggen und einen Unterbrechungspunkt hinzuzufügen, aber der my-Code geht nicht zum Ereignishandler der Zellenformatierung. Ich weiß nicht warum.C# WinForm DataGrid CellFormatting funktioniert nicht in Datenquellenprobleme
Hier ist mein Code. Ich legte meine Datenquelle in meiner Form Last
// dgv_details is supposed to be my datagrid view name.
DataTable table;
table = balreport.SelectDetails(belreport); // responsible for fetching data from the database.
this.dgv_details.DataSource = table;
this.dgv_details.Sort(this.dgv_details.Columns[0], ListSortDirection.Ascending);
// For sorting the data
foreach (DataGridViewColumn column in this.dgv_details.Columns)
{
column.SortMode = DataGridViewColumnSortMode.NotSortable;
}
this.dgv_details.CellFormatting += dgv_details_CellFormatting;
Und hier ist mein dgv_details_CellFormatting Event-Handler
if (e.ColumnIndex == 0 && e.RowIndex > 0)
{
if (dgv_salesdetails[0, e.RowIndex].Value == dgv_salesdetails[0, e.RowIndex - 1].Value)
e.Value = "";
}
Die Sortierung richtig funktioniert, aber das Problem ist, sollte die e.Value verbergen sein. Das Ergebnis sollte so etwas wie dieses Bild sein
ich wirklich Hilfe benötigen.
tun Sie auch 'e.FormattingApplied = true;' in Event-Handler – ASh
Nein, es gibt mir eine Menge Fehler in meinem Dialogfeld. :/ –
Ihr Gürtel füllt oder nicht –