Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>Yeap. You can do that in a little tricky way. I had a task to add more scale factors to zoom report. I did it this way:</p> <pre><code> private readonly string[] ZOOM_VALUES = { "25%", "50%", "75%", "100%", "110%", "120%", "125%", "130%", "140%", "150%", "175%", "200%", "300%", "400%", "500%" }; private readonly int DEFAULT_ZOOM = 3; //-- public ucReportViewer() { InitializeComponent(); this.reportViewer1.ProcessingMode = ProcessingMode.Local; setScaleFactor(ZOOM_VALUES[DEFAULT_ZOOM]); Control[] tb = reportViewer1.Controls.Find("ReportToolBar", true); ToolStrip ts; if (tb != null &amp;&amp; tb.Length &gt; 0 &amp;&amp; tb[0].Controls.Count &gt; 0 &amp;&amp; (ts = tb[0].Controls[0] as ToolStrip) != null) { //here we go if our trick works (tested at .NET Framework 2.0.50727 SP1) ToolStripComboBox tscb = new ToolStripComboBox(); tscb.DropDownStyle = ComboBoxStyle.DropDownList; tscb.Items.AddRange(ZOOM_VALUES); tscb.SelectedIndex = 3; //100% tscb.SelectedIndexChanged += new EventHandler(toolStripZoomPercent_Click); ts.Items.Add(tscb); } else { //if there is some problems - just use context menu ContextMenuStrip cmZoomMenu = new ContextMenuStrip(); for (int i = 0; i &lt; ZOOM_VALUES.Length; i++) { ToolStripMenuItem tsmi = new ToolStripMenuItem(ZOOM_VALUES[i]); tsmi.Checked = (i == DEFAULT_ZOOM); //tsmi.Tag = (IntPtr)cmZoomMenu; tsmi.Click += new EventHandler(toolStripZoomPercent_Click); cmZoomMenu.Items.Add(tsmi); } reportViewer1.ContextMenuStrip = cmZoomMenu; } } private bool setScaleFactor(string value) { try { int percent = Convert.ToInt32(value.TrimEnd('%')); reportViewer1.ZoomMode = ZoomMode.Percent; reportViewer1.ZoomPercent = percent; return true; } catch { return false; } } private void toolStripZoomPercent_Click(object sender, EventArgs e) { ToolStripMenuItem tsmi = sender as ToolStripMenuItem; ToolStripComboBox tscb = sender as ToolStripComboBox; if (tscb != null &amp;&amp; tscb.SelectedIndex &gt; -1) { setScaleFactor(tscb.Items[tscb.SelectedIndex].ToString()); } else if (tsmi != null) { if (setScaleFactor(tsmi.Text)) { foreach (ToolStripItem tsi in tsmi.Owner.Items) { ToolStripMenuItem item = tsi as ToolStripMenuItem; if (item != null &amp;&amp; item.Checked) { item.Checked = false; } } tsmi.Checked = true; } else { tsmi.Checked = false; } } } </code></pre>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload