开发者

DataGridView Matching

I have 2 DataGridViews (DGVs).

theChipDGV will contain data like this (except with many more columns):

______________________________________________________________
|  NAME  |  P/N   |  X     |  Y     |  ROTATION  |  PACKAGE  |
|________|________|________|________|____________|___________|
| R16    | 147479 | 20.325 | 100.000| 0          | 0603      |
| C6     | 14739  | -5.325 | -10.105| 180        | 0603      |
| U45    | 123456 | 12.345 | 12.345 | 45         | 0402      |
|________|________|________|________|____________|___________|

theDataBaseDGV will contain data like this (except with many more columns):

____________________________________________________________________________________________
|  PACKAGE  |  DESCRIPTION  |  FEEDER  |  VISION  |  SPEED  |  MACHINE  |  WIDTH  |  TIME  |
|___________|_______________|__________|__________|_________|___________|_________|_______ |
| PLCC20    |  N/A          | 25MM     |  N/A     |  3    开发者_运维技巧  | UNIVERSAL |  12MM   |  0.05  |
| 0603      |  0603C_1.0    | 8X4      |  1       |  1      |   FUJI-1  |  8MM    |  20    |
| 0603      |  0603R_1.0    | 12X4     |  1       |  5      |   FUJI-2  |  16MM   |  0.20  |
|___________|_______________|__________|__________|_________|___________|_________|_______ |

What I would like to do is match the column in theChipDGV labeled PACKAGE with the same labeled column in theDataBaseDGV. If there is a match, the entire row will be concatted into a new DGV (let's label it: theFinalDGV). Also, if the PACKAGE type is matched and is also in the next line (like 0603) it will check to see if the column labeled Name in theChipDGV starts with a R or a C. Depending on which it starts with will determine the rest of the columns from theDataBaseDGV that will be used.

SO:

theFinalDGV will look like this:

_____________________________________________________________________________________________________________________________________________
|  NAME  |  P/N   |  X     |  Y     |  ROTATION  |  PACKAGE  |  DESCRIPTION  |  FEEDER  |  VISION  |  SPEED  |  MACHINE  |  WIDTH  |  TIME  |
|________|________|________|________|____________|___________|_______________|__________|__________|_________|___________|_________|________|
| R16    | 147479 | 20.325 | 100.000| 0          | 0603      |  0603R_1.0    | 12X4     | 1        | 5       | FUJI-2    | 16MM    | 0.20   |
| C6     | 14739  | -5.325 | -10.105| 180        | 0603      |  0603C_1.0    | 8X4      | 1        | 1       | FUJI-1    | 8MM     | 20     |
| U45    | 123456 | 12.345 | 12.345 | 45         | 0402      |               |          |          |         |           |         |        |
|________|________|________|________|____________|___________|_______________|__________|__________|_________|___________|_________|________|

Notice, if there is no match it leaves the columns empty.

So:

Does anyone know how I can possibly go about doing this? I mostly would like to know how to match the values from 1 column with another and if there are multiple columns from theDataBaseDGV that have the same values.. then how to properly match those.


            int chipRowCount = theChipDGV.RowCount;
            int dataBaseRowCount = theDataBaseDGV.RowCount;

            for (int count = 0; count < chipRowCount; count++)
            {
                for (int i = 0; i < dataBaseRowCount; i++)
                {
                    if (theChipList[count].PkgStyle.Equals(theDataBaseList[i].PackageType) || (theChipList[count].PkgStyle.Contains(theDataBaseList[i].PackageType) &&
                        theDataBaseList[i].PartDescription.Contains("R") && theChipList[count].Name.StartsWith("R")) || ((theChipList[count].PkgStyle.Contains(theDataBaseList[i].PackageType) &&
                        theDataBaseList[i].PartDescription.Contains("C") && theChipList[count].Name.StartsWith("C"))))
                    {
                        if (!theChipList[count].Used)
                        {
                            theChipList[count].Used = true;
                            theFinalList.Add(new LoadLine(theChipList[count].Name, theChipList[count].PartNumber,
                                theChipList[count].XPlacement, theChipList[count].YPlacement, theChipList[count].Rotation,
                                theChipList[count].PkgStyle, theDataBaseList[i].PackageType, theDataBaseList[i].PartDescription,
                                theDataBaseList[i].Feeder, theDataBaseList[i].Vision, theDataBaseList[i].Speed,
                                theDataBaseList[i].Machine, theDataBaseList[i].TapeWidth, 0));

                            theFinalDGV.DataSource = theFinalList;
                        }
                    }
                }
            }

            for (int count = 0; count < theChipList.Count; count++)
            {
                if (!theChipList[count].Used)
                {
                    theFinalList.Add(new LoadLine(theChipList[count].Name, theChipList[count].PartNumber,
                        theChipList[count].XPlacement, theChipList[count].YPlacement, theChipList[count].Rotation,
                        theChipList[count].PkgStyle, string.Empty, string.Empty, string.Empty, string.Empty,
                        string.Empty, string.Empty, string.Empty, 0));
                }
            }
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜