{"record":{"id":"3152da08fc94a637","repo":"dotnet/wpf","slug":"sr-gridcolumnoutofrange-windowsstatusbar","errorCode":null,"errorMessage":"SR.GridColumnOutOfRange","messagePattern":"SR\\.GridColumnOutOfRange","errorType":"exception","errorClass":"ArgumentOutOfRangeException","httpStatus":null,"severity":"error","filePath":"src/Microsoft.DotNet.Wpf/src/UIAutomation/UIAutomationClientSideProviders/MS/Internal/AutomationProxies/WindowsStatusBar.cs","lineNumber":260,"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: 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\n        int IGridProvider.ColumnCount\n        {\n            get\n            {\n                return Count;","sourceCodeStart":242,"sourceCodeEnd":278,"githubUrl":"https://github.com/dotnet/wpf/blob/81131a70a4c573cd62748a5c36908fc4d662daa9/src/Microsoft.DotNet.Wpf/src/UIAutomation/UIAutomationClientSideProviders/MS/Internal/AutomationProxies/WindowsStatusBar.cs#L242-L278","documentation":"IGridProvider.GetItem on the Win32 status bar proxy validates the column index against the number of panes (Count). A column less than 0 or greater than or equal to the pane count throws ArgumentOutOfRangeException with SR.GridColumnOutOfRange.","triggerScenarios":"Calling IGridProvider.GetItem(0, column) with column < 0 or column >= the number of status bar panes.","commonSituations":"Assuming a fixed pane count (e.g. always 3 parts) while the application shows a different number; off-by-one loops; panes removed after a UI update while cached column indices are reused.","solutions":["Query the pane count (e.g. via IGridProvider.ColumnCount) and clamp the column before calling GetItem.","Use UIA find-all on child pane elements instead of raw grid coordinates when the layout is dynamic.","Guard the column loop bound with ColumnCount rather than a hard-coded value."],"exampleFix":"// before\nvar pane = grid.GetItem(0, 3);\n// after\nif (col >= 0 && col < grid.ColumnCount) { var pane = grid.GetItem(0, col); }","handlingStrategy":"validation","validationCode":"var grid = statusBar.GetCurrentPattern(GridPattern.Pattern) as GridPattern;\nif (column >= 0 && column < grid.ColumnCount) { var pane = grid.GetItem(0, column); }","typeGuard":"static bool IsValidColumn(GridPattern g, int col) => col >= 0 && col < g.ColumnCount;","tryCatchPattern":"try { grid.GetItem(0, col); }\ncatch (ArgumentOutOfRangeException) { /* pane does not exist */ }","preventionTips":["Query ColumnCount before accessing panes","Re-enumerate panes after UI updates instead of caching indices"],"tags":["argument-out-of-range","uiautomation","grid"],"backgroundTag":"index-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"}