Datagridview strings übernehmen

pittjupp

Grünschnabel
Hallo

habe folgendes Problem.

Ich splitte einen String und möchte das die Teilstrings in die Spalten des dgv eingefügt werden.

Wenn ich das versuche zeigt er mir den Fehler : Außerhalb des Arraybereichs an.

Code:
ArrayList a = new ArrayList();
            //Regex javascript = new Regex("script type=\\\"text/javascript\\\"\\>(?<Brutto>[^\\>]*)", RegexOptions.CultureInvariant | RegexOptions.Compiled);
            //string java = javascript.Match(this.HTML).Value;
            
            Regex trefferliste = new Regex("var cars\\=new Array(.*)([\\w+?\\.\\w+])+([a-zA-Z0-9\\~\\!\\@\\#\\$\\%\\^\\&amp;\\*\\(\\)_\\-\\=\\+\\\\\\/\\?\\.\\:\\;]*)?", RegexOptions.CultureInvariant | RegexOptions.Compiled);
            string java1 = trefferliste.Match(this.HTML).Value;
            string array = java1.Replace("var cars=new Array();", "");
            
            
            string test = array;
        string[] words = test. Split (';');
        foreach (string word in words)
        {
            a.Add(word);
            //string test1 = array;
           

            string[] words1 = word.Split(',');

            
            //string bild = words1[0];
            //string anzahlbilder = words1[1];
            //string link = words1[2];
           // string false1 = words1[3];
            //string preis = words1[4];
            //string null1 = words1[5];
            //string leer1 = words1[6];
            //string km = words1[7];
            string bj = words1[8];
           // string kw = words1[9];
            //string ps = words1[10];
            //string titel = words1[13];
            dataGridView1.Rows.Add(bj);

Vielleicht hat einer ja eine Idee. :)

Gruß
Marc
 
Hi

C#:
string bj = words1[8];
Du greifst hier hart auf ein bestimmtes Element zu. Hast du mal geprüft, ob des Element auch vorhanden ist?
 
Zurück