protected override void OnDropDownClosed(DropDownClosedEventArgs e) { base.OnDropDownClosed(e); if (_listBox.SelectedItem is ScriptValueList.ScriptEditorItem) { var scriptEditor = _provider.GetService(typeof(IScriptEditorService)) as IScriptEditorService; if (scriptEditor == null) { return; } var scriptSource = _scriptSource; if (string.IsNullOrEmpty(scriptSource)) { scriptSource = _report.DataSourceName; } object result; scriptEditor.EditScript(_report, scriptSource, _kind, this, "Expression", _scriptName, true, out result); } else if (_listBox.SelectedItem is ScriptValueList.ValueItem) { var item = _listBox.SelectedItem as ScriptValueList.ValueItem; Expression = ScriptValueHelper.TextToObject(item.Text, typeof(ScriptStringValue), item.IsExpression).ToString(); } }
protected override void OnDropDownOpened(EventArgs e) { base.OnDropDownOpened(e); DropDownForm.UpdatePerferedSize(Size); var expression = Expression; object selectedItem = null; foreach (var item in _listBox.Items) { var valueItem = item as ScriptValueList.ValueItem; if (valueItem == null) { continue; } var itemExpression = ScriptValueHelper.TextToObject(valueItem.Text, typeof(ScriptStringValue), valueItem.IsExpression).ToString(); if (expression == itemExpression) { selectedItem = item; break; } } _listBox.SelectedItem = selectedItem; }