private void _btnEditConnection_Click(object sender, EventArgs e) { DataProviderDesc dpd = _cbDataProvider.SelectedItem as DataProviderDesc; DsgnDataLinkBase dl; if (dpd == null || dpd.Link == DsgnAutoLink.Instance) { // auto link can not be used for editing parameters // we should determine real type of connection string // and use needed Link class dl = DsgnAutoLink.Instance.GetRealLink(this); } else { dl = dpd.Link; } try { string connectionString = _cbConnectionString.Text; if (dl.EditConnection(this, ref connectionString)) { SetDataSource(dl.DataProvider, connectionString, RecordSource); } } catch (Exception ex) { DataSourceForm.ReportDataSourceError(string.Format(Strings.DataSourcePicker.ErrCannotEditConnFmt, ex.Message)); } ActiveControl = _cbConnectionString; }
// updates state of buttons linked with other controls private void UpdateButtons() { DataProviderDesc dpd = _cbDataProvider.SelectedItem as DataProviderDesc; _btnEditConnection.Enabled = dpd != null && dpd.Link.Available; _btnDataSourceProperties.Enabled = _tvDataSource.SelectedNode != null && _tvDataSource.SelectedNode.Tag is ExternalRecordsetDesc; _btnQueryBuilder.Enabled = dpd != null && dpd.Link == DsgnOledbLink.Instance; }
private void _cbDataProvider_DrawItem(object sender, DrawItemEventArgs e) { DataProviderDesc dpd = (DataProviderDesc)_cbDataProvider.Items[e.Index]; e.DrawBackground(); Color color; if ((e.State & DrawItemState.Selected) != 0) { color = SystemColors.HighlightText; } else { color = dpd.Link.Available ? SystemColors.WindowText : SystemColors.GrayText; } TextRenderer.DrawText(e.Graphics, dpd.ToString(), _cbDataProvider.Font, e.Bounds, color, TextFormatFlags.Left | TextFormatFlags.VerticalCenter); e.DrawFocusRectangle(); }
private void _cbDataProvider_SelectedIndexChanged(object sender, EventArgs e) { if (Updating) { return; } // check connection string and clear it if it is not valid // for selected data provider DataProviderDesc dpd = _cbDataProvider.SelectedItem as DataProviderDesc; if (dpd.Link != DsgnAutoLink.Instance) { if (!dpd.Link.Link.Available) { // selected data provider is not installed on the system // show warning for user MessageForm.Warn(string.Format(Strings.DataSourcePicker.ProviderNotInstalledFmt, dpd.Link.Caption)); _cbConnectionString.Text = string.Empty; } else { DataLinkParams dlp = new DataLinkParams(); dlp.ConnectionString = _cbConnectionString.Text; if (DataSource != null) { dlp.Report = DataSource.ParentReport; } if (!dpd.Link.Link.Validate(dlp)) { // connection string is not valid clear it _cbConnectionString.Text = string.Empty; } } } ConnectionStringChanged(RecordSource); }