簡體   English   中英

使用LINQ獲取DataGridView行值,其中第三列具有特定值

[英]Using LINQ to get DataGridView row value where third column has specific value

我想從DataGridViewRow獲取一個單元格的值,其第三列的值匹配。

但System.ArgumentOutOfRangeException類型的例外情況“索引超出范圍。必須是非負數且小於集合的大小。” 已經發生了。

我的代碼如下:

 for (int i = 0; i <= intranumber; i++)
        {    
           string source = (string)(from r in dataGridView5.Rows.Cast<DataGridViewRow>()  
                             where   (string)r.Cells[3].Value== intra[i].Item1
                             select r.Cells[1].Value.ToString()).First();

我認為你的問題是intra [i]。 如果intranumber是intra.count。 所以你必須擁有我

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM