Zum Inhalt springen
View in the app

A better way to browse. Learn more.

Fachinformatiker.de

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

DataGridView, DataTable, Cellstyle

Empfohlene Antworten

Veröffentlicht

Hallo,

ich habe das Problem das ich den Fontstyle für bestimmte Zellen in meinen DataGridView nicht ändern kann. Die Daten für das Grid werden mittels einer DataTable eingefügt. Ich nehme an, das der Style der DataTable den Style des Grid überschreibt. Weil wie man den Fontstyle in einen Grid ändert weiß ich, geht auch ohne Probleme, nur wenn die eingebunden Daten vom DataTable kommen geht es nicht.

Ich habe auch schon mal geschaut ob man den DataTable einen Style mitgeben kann, aber das geht ja auch nicht. Komischerweise kann ich den Columns einen Style geben, nur den Zellen nicht.

Hier mein Code:


public void ShowIt(DataTable table)

        {

            dataGridView1.DataSource = table;

            dataGridView1.Sort(this.dataGridView1.Columns["Fach"], ListSortDirection.Ascending);

            dataGridView1.Columns[3].DefaultCellStyle.Font = new Font(dataGridView1.DefaultCellStyle.Font, FontStyle.Bold);

            DataGridViewCell cell = dataGridView1.Rows[0].Cells[1];

                cell.Style = new DataGridViewCellStyle()

                {

                    BackColor = Color.Pink,

                    Font = new Font("Tahoma", 8F),

                    ForeColor = SystemColors.WindowText,

                    SelectionBackColor = Color.Red,

                    SelectionForeColor = SystemColors.HighlightText

                };            

        }

Wäre über jeden Tipp dankbar.

Danke und Gruß

onz

Archiv

Dieses Thema wurde archiviert und kann nicht mehr beantwortet werden.

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.