#region License // Copyright 2005-2019 Paul Kohler (https://github.com/paulkohler/minisqlquery). All rights reserved. // This source code is made available under the terms of the GNU Lesser General Public License v3.0 // https://github.com/paulkohler/minisqlquery/blob/master/LICENSE #endregion using System; using System.Windows.Forms; namespace MiniSqlQuery.Core.Controls { /// A batch query selection control is used for displaying multiple result sets and allows /// the user to select one (e.g. for exports etc). public partial class BatchQuerySelectControl : UserControl { /// The _batch. private QueryBatch _batch; /// The _selected query. private Query _selectedQuery; /// /// Initializes a new instance of the class. /// public BatchQuerySelectControl() { InitializeComponent(); } /// /// Gets the selected query. /// /// The selected query. public Query SelectedQuery { get { return _selectedQuery; } } /// Fills the list with the batch result sets. /// The query batch. public void Fill(QueryBatch batch) { _batch = batch; lstBatches.Items.Clear(); if (batch == null) { return; } for (int setIndex = 0; setIndex < batch.Queries.Count; setIndex++) { var query = batch.Queries[setIndex]; if (query.Result != null && query.Result.Tables.Count > 0) { string setName = string.Format("Result Set {0} ({1} tables)", setIndex, query.Result.Tables.Count); lstBatches.Items.Add(setName); } } lstBatches.SelectedIndex = 0; } /// The lst batches_ selected index changed. /// The sender. /// The e. private void lstBatches_SelectedIndexChanged(object sender, EventArgs e) { _selectedQuery = _batch.Queries[lstBatches.SelectedIndex]; } } }