{"record":{"id":"d74d5f7f1718bc48","repo":"dotnet/wpf","slug":"specified-argument-was-out-of-the-range-of-valid-values-d74d5f","errorCode":null,"errorMessage":"Specified argument was out of the range of valid values. (Parameter 'column') Grid column must be set between 0 and column maximum.","messagePattern":"Specified argument was out of the range of valid values\\. \\(Parameter 'column'\\) Grid column must be set between 0 and column maximum\\.","errorType":"exception","errorClass":"ArgumentOutOfRangeException","httpStatus":null,"severity":"error","filePath":"src/Microsoft.DotNet.Wpf/src/UIAutomation/UIAutomationClientSideProviders/MS/Internal/AutomationProxies/WindowsIPAddress.cs","lineNumber":180,"sourceCode":"        }\n\n        #endregion\n\n        #region Grid Pattern\n\n        // Obtain the AutomationElement at an zero based absolute position in the grid.\n        // Where 0,0 is top left\n        IRawElementProviderSimple IGridProvider.GetItem(int row, int column)\n        {\n            // NOTE: IPAddress has only 1 row\n            if (row != 0)\n            {\n                throw new ArgumentOutOfRangeException(nameof(row), row, SR.GridRowOutOfRange);\n            }\n\n            if (column < 0 || column >= OCTETCOUNT)\n            {\n                throw new ArgumentOutOfRangeException(nameof(column), column, SR.GridColumnOutOfRange);\n            }\n\n            // Note: GridItem position is in reverse from the hwnd position\n            // take this into account\n            column = OCTETCOUNT - (column + 1);\n            IntPtr hwndChild = GetChildWindowFromIndex(column);\n            if (hwndChild != IntPtr.Zero)\n            {\n                return new ByteEditBoxOverride(hwndChild, column);\n            }\n            return null;\n        }\n\n        int IGridProvider.RowCount\n        {\n            get\n            {\n                return 1;","sourceCodeStart":162,"sourceCodeEnd":198,"githubUrl":"https://github.com/dotnet/wpf/blob/81131a70a4c573cd62748a5c36908fc4d662daa9/src/Microsoft.DotNet.Wpf/src/UIAutomation/UIAutomationClientSideProviders/MS/Internal/AutomationProxies/WindowsIPAddress.cs#L162-L198","documentation":"WindowsIPAddress's IGridProvider.GetItem throws ArgumentOutOfRangeException when the column index is outside the valid range 0–3 (OCTETCOUNT): an IP address grid has four columns, one per octet, and only row 0. The automation client passed a column beyond the grid bounds.","triggerScenarios":"Calling IGridProvider.GetItem(row, column) with column = -1 or column >= 4 (e.g. assuming 8 or 32 fields, or 1-based indexing).","commonSituations":"Off-by-one errors using 1-based column indices (1..4 instead of 0..3); code reused from other grid controls with more columns.","solutions":["Use 0-based columns 0..3 (OCTETCOUNT-1)","Check GridPattern.Current.ColumnCount before iterating","Catch ArgumentOutOfRangeException and clamp/log the bad column","Remember GetItem internally reverses the column order (column = OCTETCOUNT - (column+1)) but expects 0-based input"],"exampleFix":"// before\nvar item = grid.GetItem(0, 4); // wrong: 1-based\n// after\nvar item = grid.GetItem(0, 3); // 4th octet, 0-based","handlingStrategy":"validation","validationCode":"if (column < 0 || column >= 4) throw new ArgumentOutOfRangeException(nameof(column), column, \"IP grid columns are 0..3.\");","typeGuard":null,"tryCatchPattern":"try { grid.GetItem(row, column); }\ncatch (ArgumentOutOfRangeException) { /* out-of-bounds column: clamp to 0..3 */ }","preventionTips":["Use 0-based columns 0..3 (OCTETCOUNT)","Check GridPattern.ColumnCount before iterating","Do not reuse 1-based indexing from other controls","Clamp columns in generic grid-walk helpers"],"tags":["uiautomation","argumentoutofrange","gridpattern","column"],"backgroundTag":"argument-out-of-range","analyzedSha":"81131a70a4c573cd62748a5c36908fc4d662daa9","analyzedAt":"2026-09-14T10:12:48.479Z","contentChangedAt":"2026-09-14T10:12:48.479Z","schemaVersion":2},"datasetVersion":"2026-09-21T21:30:21.729Z"}