Skip to content

Fix crash when adding Table/Chart/Matrix to a report with no datasets#269

Merged
majorsilence merged 2 commits intomasterfrom
copilot/fix-invalid-argument-error
Feb 24, 2026
Merged

Fix crash when adding Table/Chart/Matrix to a report with no datasets#269
majorsilence merged 2 commits intomasterfrom
copilot/fix-invalid-argument-error

Conversation

Copy link
Contributor

Copilot AI commented Feb 22, 2026

Opening a Table, Chart, or Matrix dialog on an empty report (no datasets defined) throws an unhandled ArgumentException because cbDataSets.SelectedIndex = 0 is called unconditionally on an empty ComboBox.

Changes

  • DialogNewTable.cs, DialogNewChart.cs, DialogNewMatrix.cs: Guard SelectedIndex assignment with an item count check in each dialog's constructor.
// Before — throws when no datasets exist
cbDataSets.SelectedIndex = 0;

// After — safe when ComboBox is empty
if (cbDataSets.Items.Count > 0)
    cbDataSets.SelectedIndex = 0;
Original prompt

This section details on the original issue you should resolve

<issue_title>InvalidArgument=Value of '0'</issue_title>
<issue_description>Describe the bug
A clear and concise description of what the bug is.
Designer is getting errors
To Reproduce
Steps to reproduce the behavior:

  1. Go to 'Firstly create an empty report"
  2. Click Tables/Chart/List'
  3. Click on ''body"
  4. See error

Expected behavior
Create a table

Screenshots

Image

Additional context
Add any other context about the problem here.
</issue_description>

Comments on the Issue (you are @copilot in this section)


💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.

Co-authored-by: majorsilence <656288+majorsilence@users.noreply.github.com>
Copilot AI changed the title [WIP] Fix invalid argument error when creating a report Fix crash when adding Table/Chart/Matrix to a report with no datasets Feb 22, 2026
Copilot AI requested a review from majorsilence February 22, 2026 23:09
@majorsilence majorsilence marked this pull request as ready for review February 24, 2026 23:20
Copilot AI review requested due to automatic review settings February 24, 2026 23:20
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This pull request fixes a crash that occurs when opening Table, Chart, or Matrix dialogs on reports with no datasets defined. The issue is caused by unconditionally setting SelectedIndex = 0 on an empty ComboBox, which throws an ArgumentException.

Changes:

  • Added defensive guards to check Items.Count > 0 before setting SelectedIndex = 0 in three dialog initialization methods
  • The fix prevents the crash while maintaining correct behavior when datasets are present
  • The pattern used matches existing conventions in the codebase (e.g., DialogDataSources, ReportParameterCtl)

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated no comments.

File Description
RdlDesign/DialogNewTable.cs Added guard to prevent setting SelectedIndex on empty cbDataSets ComboBox
RdlDesign/DialogNewMatrix.cs Added guard to prevent setting SelectedIndex on empty cbDataSets ComboBox
RdlDesign/DialogNewChart.cs Added guard to prevent setting SelectedIndex on empty cbDataSets ComboBox

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@majorsilence majorsilence merged commit 465f9a4 into master Feb 24, 2026
9 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

InvalidArgument=Value of '0'

3 participants