{"record":{"id":"326756da75492e9e","repo":"dotnet/wpf","slug":"sr-gridrowoutofrange-windowsstatusbar","errorCode":null,"errorMessage":"SR.GridRowOutOfRange","messagePattern":"SR\\.GridRowOutOfRange","errorType":"exception","errorClass":"ArgumentOutOfRangeException","httpStatus":null,"severity":"error","filePath":"src/Microsoft.DotNet.Wpf/src/UIAutomation/UIAutomationClientSideProviders/MS/Internal/AutomationProxies/WindowsStatusBar.cs","lineNumber":255,"sourceCode":"                    ProxySimple grip = StatusBarGrip.Create(_hwnd, this, -1);\n                    return (ProxySimple)(grip ?? this);\n                }\n            }\n            return this;\n        }\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: Status bar 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 >= Count)\n            {\n                throw new ArgumentOutOfRangeException(nameof(column), column, SR.GridColumnOutOfRange);\n            }\n\n            return CreateStatusBarPane(column);\n        }\n\n        int IGridProvider.RowCount\n        {\n            get\n            {\n                return 1;\n            }\n        }\n","sourceCodeStart":237,"sourceCodeEnd":273,"githubUrl":"https://github.com/dotnet/wpf/blob/81131a70a4c573cd62748a5c36908fc4d662daa9/src/Microsoft.DotNet.Wpf/src/UIAutomation/UIAutomationClientSideProviders/MS/Internal/AutomationProxies/WindowsStatusBar.cs#L237-L273","documentation":"IGridProvider.GetItem on the Win32 status bar proxy only supports a single row (row 0). Requesting any row other than 0 throws ArgumentOutOfRangeException with SR.GridRowOutOfRange. This reflects the fixed physical layout of a status bar: one row of panes.","triggerScenarios":"Calling IGridProvider.GetItem(row, column) on a status bar element with row != 0.","commonSituations":"Generic grid-walking automation code that iterates rows 0..RowCount-1 but is fed a wrong row bound; treating a status bar as a multi-row grid; copy-pasted grid logic from ListView/DataGridView scenarios.","solutions":["Pass 0 as the row when calling GetItem on a status bar grid provider.","Check IGridProvider.RowCount (always 1 for status bars) before iterating rows.","Wrap GetItem in a check that skips statuses/rows greater than RowCount-1."],"exampleFix":"// before\nfor (int row = 0; row < assumedRows; row++) grid.GetItem(row, col);\n// after\nint rows = gridProvider.RowCount;\nfor (int row = 0; row < rows; row++) gridProvider.GetItem(row, col);","handlingStrategy":"validation","validationCode":"var grid = statusBar.GetCurrentPattern(GridPattern.Pattern) as GridPattern;\nif (row < 0 || row >= grid.RowCount) throw new InvalidOperationException(\"row out of range\");\nvar item = grid.GetItem(row, column);","typeGuard":"static bool IsValidRow(GridPattern g, int row) => row >= 0 && row < g.RowCount;","tryCatchPattern":"try { grid.GetItem(row, col); }\ncatch (ArgumentOutOfRangeException) { /* treat as no such cell */ }","preventionTips":["Use RowCount/ColumnCount as loop bounds, never hard-coded sizes","Remember status bars are single-row grids"],"tags":["argument-out-of-range","uiautomation","grid"],"backgroundTag":"value-out-of-range","analyzedSha":"81131a70a4c573cd62748a5c36908fc4d662daa9","analyzedAt":"2026-09-14T10:12:48.479Z","contentChangedAt":"2026-09-14T10:12:48.479Z","schemaVersion":2},"datasetVersion":"2026-09-22T01:17:13.364Z"}