Autor Beitrag
Questioneer
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 32



BeitragVerfasst: Di 21.10.08 12:16 
Hi,

ich hab noch ein kleines Problem mit einem DataGridView.
Ich möchte in ein leeres DataGridView Spalten einfügen und zwar über meinen :!: Code :!: nicht über das Eigenschaften-Menue .

Könnt Ihr mir da weiterhelfen ? :?:

Vilen dank :!:
Questioneer
Questioneer Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 32



BeitragVerfasst: Di 21.10.08 13:32 
Hi,

ich habs jetzt so gelöst:

ausblenden C#-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
            int iGridWidth = btBmpBytes[18];

            for (int i = 0; i <= iGridWidth; i++)
            {
                DataGridViewTextBoxColumn filterCol = new DataGridViewTextBoxColumn();

                filterCol.HeaderText = i.ToString();
                filterCol.ReadOnly = true// User darf nicht editieren
                filterCol.SortMode = DataGridViewColumnSortMode.NotSortable;
                dgBmpDaten.Columns.Insert(i, filterCol);
               
            }



Es funzt zwar, aber mich würde interessieren ob die Lösung so gut ist oder ob man das anders coden sollte ?


P.S. : Wie kann ich meinen Code farbig einfügen ?

Gruß
Questioneer

Moderiert von user profile iconChristian S.: Code- durch C#-Tags ersetzt
Christian S.
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 20451
Erhaltene Danke: 2264

Win 10
C# (VS 2019)
BeitragVerfasst: Di 21.10.08 13:50 
user profile iconQuestioneer hat folgendes geschrieben Zum zitierten Posting springen:
P.S. : Wie kann ich meinen Code farbig einfügen ?
Indem Du [cs]...[/cs] statt [code]...[/code] schreibst :-)

_________________
Zwei Worte werden Dir im Leben viele Türen öffnen - "ziehen" und "drücken".
Kha
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 3803
Erhaltene Danke: 176

Arch Linux
Python, C, C++ (vim)
BeitragVerfasst: Di 21.10.08 13:52 
Große Optimierungsmöglichkeiten seh ich da nicht :), aber wenn du es unbedingt kürzer haben willst:
ausblenden C#-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
  int iGridWidth = btBmpBytes[18];

  for (int i = 0; i <= iGridWidth; i++)
    dgBmpDaten.Columns.Insert(i, 
      new DataGridViewTextBoxColumn {
        HeaderText = i.ToString(),
        ReadOnly = true// User darf nicht editieren
        SortMode = DataGridViewColumnSortMode.NotSortable });

(VS2008)

_________________
>λ=
Questioneer Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 32



BeitragVerfasst: Di 21.10.08 14:59 
Danke ;) !!!

BTW, wisst Ihr vllt. zufällig wie ich die Header der Zeilen (= RowHeader ???) beschtifte ?


Gruß und danke
Questioneer
Christian S.
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 20451
Erhaltene Danke: 2264

Win 10
C# (VS 2019)
BeitragVerfasst: Di 21.10.08 15:02 
Hallo!

Bitte erstelle für eine neue Frage auch ein neues Topic. Dann stimmt auch der Titel ;-) Danke! :-)

Grüße
Christian

_________________
Zwei Worte werden Dir im Leben viele Türen öffnen - "ziehen" und "drücken".
Dieses Thema ist gesperrt, Du kannst keine Beiträge editieren oder beantworten.

Das Thema wurde von einem Team-Mitglied geschlossen. Wenn du mit der Schließung des Themas nicht einverstanden bist, kontaktiere bitte das Team.