views:

52

answers:

2

I'm using the ReportViewer control in a WinForms app. How do I change the "NULL" checkbox text to anything else? (just right of 'Begin Date' in the below picture)

alt text

+1  A: 

Edit the report and uncheck the 'Allow NULL value' checkboxes for those parameters. You can use the 'Allow blank value' without the additional checkboxes displaying.

Kenneth
blank isn't the same as null, I'd have to change all my queries?
mgroves
Correct, it isn't the same. You may or may not have to change the queries, I can't say. You could always NULL out the variable by checking the LEN in your query. Regardless, it's the only way I know of to remove the box and still not require a value.
Kenneth
Also, I can't allow null for float/date. So I'd have to do some parsing in the queries then too
mgroves
It turns out, the customer changed their mind and wanted this method instead of checkboxes. Whatever :)
mgroves
+2  A: 

Here's the answer, and it's a bit ugly, but hopefully this will save you some typing if you ever have to do it yourself. Implement the IReportViewerMessages interface like so:

public class CustomReportViewerMessages : IReportViewerMessages
{
    public string NullCheckBoxText { get { return "All"; } }
    public string NullCheckBoxToolTip { get { return "All"; } }

    public string DocumentMapButtonToolTip { get { return "DocumentMapButtonToolTip"; } }
    public string ParameterAreaButtonToolTip { get { return "ParameterAreaButtonToolTip"; } }
    public string FirstPageButtonToolTip { get { return "FirstPageButtonToolTip"; } }
    public string PreviousPageButtonToolTip { get { return "PreviousPageButtonToolTip"; } }
    public string CurrentPageTextBoxToolTip { get { return "CurrentPageTextBoxToolTip"; } }
    public string PageOf { get { return "PageOf"; } }
    public string NextPageButtonToolTip { get { return "NextPageButtonToolTip"; } }
    public string LastPageButtonToolTip { get { return "LastPageButtonToolTip"; } }
    public string BackButtonToolTip { get { return "BackButtonToolTip"; } }
    public string RefreshButtonToolTip { get { return "RefreshButtonToolTip"; } }
    public string PrintButtonToolTip { get { return "PrintButtonToolTip"; } }
    public string ExportButtonToolTip { get { return "ExportButtonToolTip"; } }
    public string ZoomControlToolTip { get { return "ZoomControlToolTip"; } }
    public string SearchTextBoxToolTip { get { return "SearchTextBoxToolTip"; } }
    public string FindButtonToolTip { get { return "FindButtonToolTip"; } }
    public string FindNextButtonToolTip { get { return "FindNextButtonToolTip"; } }
    public string ZoomToPageWidth { get { return "ZoomToPageWidth"; } }
    public string ZoomToWholePage { get { return "ZoomToWholePage"; } }
    public string FindButtonText { get { return "FindButtonText"; } }
    public string FindNextButtonText { get { return "FindNextButtonText"; } }
    public string ViewReportButtonText { get { return "ViewReportButtonText"; } }
    public string ProgressText { get { return "ProgressText"; } }
    public string TextNotFound { get { return "TextNotFound"; } }
    public string NoMoreMatches { get { return "NoMoreMatches"; } }
    public string ChangeCredentialsText { get { return "ChangeCredentialsText"; } }
    public string NullValueText { get { return "NullValueText"; } }
    public string TrueValueText { get { return "TrueValueText"; } }
    public string FalseValueText { get { return "FalseValueText"; } }
    public string SelectAValue { get { return "SelectAValue"; } }
    public string UserNamePrompt { get { return "UserNamePrompt"; } }
    public string PasswordPrompt { get { return "PasswordPrompt"; } }
    public string SelectAll { get { return "SelectAll"; } }
    public string PrintLayoutButtonToolTip { get { return "PrintLayoutButtonToolTip"; } }
    public string PageSetupButtonToolTip { get { return "PageSetupButtonToolTip"; } }
    public string TotalPagesToolTip { get { return "TotalPagesToolTip"; } }
    public string StopButtonToolTip { get { return "StopButtonToolTip"; } }
    public string DocumentMapMenuItemText { get { return "DocumentMapMenuItemText"; } }
    public string BackMenuItemText { get { return "BackMenuItemText"; } }
    public string RefreshMenuItemText { get { return "RefreshMenuItemText"; } }
    public string PrintMenuItemText { get { return "PrintMenuItemText"; } }
    public string PrintLayoutMenuItemText { get { return "PrintLayoutMenuItemText"; } }
    public string PageSetupMenuItemText { get { return "PageSetupMenuItemText"; } }
    public string ExportMenuItemText { get { return "ExportMenuItemText"; } }
    public string StopMenuItemText { get { return "StopMenuItemText"; } }
    public string ZoomMenuItemText { get { return "ZoomMenuItemText"; } }
    public string ViewReportButtonToolTip { get { return "ViewReportButtonToolTip"; } }
}

Then, use an instance of that class right before you RefreshReport:

                reportViewer.Messages = new CustomReportViewerMessages();
                reportViewer.RefreshReport();

And that'll do it. Notice I've left almost all the properties as meaningless strings, except the two (at top) that I care about.

mgroves