Maxim Voloshin
Maxim Voloshin

Reputation: 61

How to format cells inside DataGridView more effectively

I'm writing ID3 tag editor and I have DataGridView there. I have ID3 frame IDs ("TIT1", "TIT2", etc) and I want to display corresponding labels instead of them ("Title 1", "Title 2", etc)... So I used CellFormatting, but I notice that such event is called much more times than I really need and it makes my program slower. Is there a better way to implement that? I need formatting cells just when a new row is added to the DataGridView.

private void dataGridView1_CellFormatting(object sender, DataGridViewCellFormattingEventArgs e)
        {
                    if (known_frameIDs_current.Contains(e.Value))
                    {
                        e.Value = frameID_labels[Array.IndexOf(known_frameIDs_current,e.Value), isEnglish];
                    }
                    e.FormattingApplied = true;
        }

Upvotes: 0

Views: 42

Answers (1)

Maxim Voloshin
Maxim Voloshin

Reputation: 61

Thanks. I've rewritten the code using RowsAdded

Upvotes: 0

Related Questions