SQLExpressionDialog without DialogResult on OK Button

Jun 6, 2012 at 1:48 PM

Hi,

I am using this form in my app and want to set this code:

If qd.DialogResult = Windows.Forms.DialogResult.OK Then

 

 If Not [String].IsNullOrWhiteSpace(qd.Expression)  

Then

Try

 

 

 

_featureLayer.SelectByAttribute(qd.Expression)

but the result is always Cancel anyhow I click on the OK or Cancel Button

Now i saw in the sorce the DialogResult is not set for the OK Button.

 

// btnCancel
            //
            resources.ApplyResources(this.btnCancel, "btnCancel");
            this.btnCancel.DialogResult = System.Windows.Forms.DialogResult.Cancel;
            this.btnCancel.Name = "btnCancel";
            this.btnCancel.UseVisualStyleBackColor = true;
            this.btnCancel.Click += new System.EventHandler(this.btnCancel_Click);
            //
            // cmdOk
            //
            resources.ApplyResources(this.cmdOk, "cmdOk");
            this.cmdOk.Name = "cmdOk";
            this.cmdOk.UseVisualStyleBackColor = true;
            this.cmdOk.Click += new System.EventHandler(this.cmdOk_Click);
            //
Developer
Jun 6, 2012 at 4:06 PM

To what form does qd refer?

Jun 6, 2012 at 6:36 PM

Dim qd As SQLExpressionDialog = New SQLExpressionDialog

from DotSpatial.Symbology.Forms

You can see at the new Demo Map from DotSpatial 1.2 the same problem.

If you enter an expression in the dialog and click Cancel the same happens as you click OK, the query is executed.

This is the code from FindFeaturePlugin the DialogResult is not used here.

SQLExpressionDialog qd = new SQLExpressionDialog();
            if (fl.DataSet.AttributesPopulated)
                qd.Table = fl.DataSet.DataTable;
            else
                qd.AttributeSource = fl.DataSet;

            // Note: User must click ok button to see anything.
            qd.ShowDialog();

            if (!String.IsNullOrWhiteSpace(qd.Expression))
            {
                try
                {
                    fl.SelectByAttribute(qd.Expression);
                }
                catch (SyntaxErrorException ex)
                {
                    MessageBox.Show("The syntax of that query isn't quite right: " + ex.Message);
                }
            }
Developer
Jun 6, 2012 at 9:08 PM

Sorry, I just noticed the title of the discussion. 

 

You will find this is fixed in the latest changeset (67477).