BookmarkSubscribeRSS Feed
deleted_user
Not applicable
Hi every one,

I am building a custom Task, and I would like to add a SAS editor control for code preview in my task. What control should I use? I don’t want to use the .NET TextBox.

(When I add SAS.EG.Controls.dll to my .NET project reference and to the ToolBox, many SAS-supplied controls such as SASDatasetSelector appear, but there is no SAS editor control).

Thanks for any help,

Maurice
11 REPLIES 11
ChrisHemedinger
Community Manager
Maurice,

In the examples on our web site at http://support.sas.com/eguide, there are a few tasks that show this. For example, the "SAS Catalog Explorer" and the "Simple SAS Program Editor" use the enhanced editor.

The key assemblies are SAS.AxInterop.EDITORCONTROLLib.dll and SAS.Interop.EDITORCONTROLLib.dll.

Chris
It's time to register for SAS Innovate! Join your SAS user peers in Las Vegas on April 16-19 2024.
deleted_user
Not applicable
Thanks Chris,

I downloaded the examples, AxInterop.EDITORCONTROLLib.dll and Interop.EDITORCONTROLLib.dll must be referenced.
But unlike the controls in the SAS.EG.Controls.dll, it seems not possible to add the editor control on the toolbox so that it can be drag and dropped on the form (Error message: “There are no components in ‘C:\Program Files\SAS\Enterprise Guide 4\SAS.AxInterop.EDITORCONTROLLib.dll’ that can be placed on the toolbox.”)....

Thanks,

Maurice
ChrisHemedinger
Community Manager
In EG 4.1, the assemblies have the "SAS." prefix in their names.

I don't recommend using the designer to deal with the enhanced editor control. Instead, I would use a placeholder control (like a panel) and then dynamically create the editor control when your form is loaded.

For example, declare this:

[pre]
private AxEDITORCONTROLLib.AxEditorControl ctlEditor = null;
[/pre]

Then in OnLoad(), do this:

[pre]
ctlEditor = new AxEDITORCONTROLLib.AxEditorControl();
ctlEditor.Location = panelPlaceholder.Location;
ctlEditor.Visible = true;
ctlEditor.Dock = panelPlaceholder.Dock;

// add handler for when the control is finished being created
ctlEditor.HandleCreated += new EventHandler(ctlEditor_HandleCreated);

this.Controls.AddRange(new System.Windows.Forms.Control[] {this.ctlEditor});
[/pre]

Then be sure not to reference the control's methods until the handle is created. This is not uncommon when dealing with ActiveX controls via COM interop. It might take a moment to initialize, and you cannot call into it before it's ready.

[pre]
// control is created - now open file
private void ctlEditor_HandleCreated(object sender, EventArgs e)
{
if (file.Length>0)
ctlEditor.OpenFile(file);
ctlEditor.SetLanguage(4); // set language to SAS for syntax coloring
}
[/pre]

Chris
It's time to register for SAS Innovate! Join your SAS user peers in Las Vegas on April 16-19 2024.
Florian_Dymatrix
Calcite | Level 5
Is there any way to utilize the Editor control as as SAS-Log control?

How to enable SAS-Log syntax-highlighting such as red error-messages? Can I use the SetLanguage method? But which integer value to set?
ChrisHemedinger
Community Manager
If you are using EG 4.2, you can use the new SAS.Tasks.Toolkit library to simplify this.

The control you want is in SAS.Tasks.Toolkit.dll, and the control is:

SAS.Tasks.Toolkit.Controls.SASTextEditorCtl

It has a property that you can set:

ContentType = SAS.Tasks.Toolkit.Controls.SASTextEditorCtl.eContentType.SASProgram;

or

ContentType =
SAS.Tasks.Toolkit.Controls.SASTextEditorCtl.eContentType.SASLog

Chris
It's time to register for SAS Innovate! Join your SAS user peers in Las Vegas on April 16-19 2024.
Florian_Dymatrix
Calcite | Level 5
Dear Chris,

unfortunately we are using EG 4.1. Is there another way using this version?

Thanks, Florian
sbb
Lapis Lazuli | Level 10 sbb
Lapis Lazuli | Level 10
Please, in the future, create a new forum post, rather than piggy-backing on a 3 year old post from another individual -- it's realistic to paste a link to the prior post but to simply REPLY to someone else's closed post is unreasonable.

Scott Barry
SBBWorks, Inc.
ChrisHemedinger
Community Manager
Okay, okay. The magic number is....

6

Recommend that you set the properties in this order (assuming you like your log view to be read-only):

editor.ReadOnly=true;
editor.SetLanguage(6);

Chris
It's time to register for SAS Innovate! Join your SAS user peers in Las Vegas on April 16-19 2024.
Victor
Calcite | Level 5

Hello Chris

Note    I use VB 2008, Guide 4.3

I followed your instructions to insert an editor in a Cutom Task. But on a machine equiped by only Enterprise Guide, i got this error:

System.Runtime.InteropServices.COMException

Classe non enregistrée (Exception de HRESULT : 0x80040154 (REGDB_E_CLASSNOTREG))

------------------------------ Début des informations techniques------------------------------

System.Runtime.InteropServices.COMException (0x80040154): Classe non enregistrée (Exception de HRESULT : 0x80040154 (REGDB_E_CLASSNOTREG))
   à System.Windows.Forms.UnsafeNativeMethods.CoCreateInstance(Guid& clsid, Object punkOuter, Int32 context, Guid& iid)
   à System.Windows.Forms.AxHost.CreateWithoutLicense(Guid clsid)
   à System.Windows.Forms.AxHost.CreateWithLicense(String license, Guid clsid)
   à System.Windows.Forms.AxHost.CreateInstanceCore(Guid clsid)
   à System.Windows.Forms.AxHost.CreateInstance()
   à System.Windows.Forms.AxHost.GetOcxCreate()
   à System.Windows.Forms.AxHost.TransitionUpTo(Int32 state)
   à System.Windows.Forms.AxHost.CreateHandle()
   à System.Windows.Forms.Control.CreateControl(Boolean fIgnoreVisible)
   à System.Windows.Forms.Control.CreateControl(Boolean fIgnoreVisible)
   à System.Windows.Forms.Control.CreateControl(Boolean fIgnoreVisible)
   à System.Windows.Forms.Control.CreateControl()
   à System.Windows.Forms.Control.SetVisibleCore(Boolean value)
   à System.Windows.Forms.TabPage.set_Visible(Boolean value)
   à System.Windows.Forms.TabControl.UpdateTabSelection(Boolean updateFocus)
   à System.Windows.Forms.TabControl.OnSelectedIndexChanged(EventArgs e)
   à System.Windows.Forms.TabControl.WmSelChange()
   à System.Windows.Forms.TabControl.WndProc(Message& m)
   à System.Windows.Forms.Control.ControlNativeWindow.OnMessage(Message& m)
   à System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message& m)
   à System.Windows.Forms.NativeWindow.Callback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)

ChrisHemedinger
Community Manager

Victor,

In EG 4.3 the process is different, but even easier.  You can simply use the SAS.Tasks.Toolkit.Controls.SASTextEditorCtl class.

There are examples here:

  http://go.sas.com/customtasksapi

See the SAS Program Runner project, for example.

Also, this is described in my book: Custom Tasks for SAS Enterprise Guide using Microsoft .NET

The book features an example in Chapter 12, and the source code for that project is available here (and described in this blog post😞

Custom Tasks for SAS Enterprise Guide using Microsoft .NET (Examples)

And finally, you can also see the same source code on GitHub:

cjdinger/SasDatasetToDataStep · GitHub

Specifically:

SasDatasetToDataStep/src/DS2DatalinesForm.cs at master · cjdinger/SasDatasetToDataStep · GitHub

Chris

It's time to register for SAS Innovate! Join your SAS user peers in Las Vegas on April 16-19 2024.
Victor
Calcite | Level 5

This is what i finally did. It's so simple.

I should look your book more often.

Thank's any way

sas-innovate-2024.png

Join us for SAS Innovate April 16-19 at the Aria in Las Vegas. Bring the team and save big with our group pricing for a limited time only.

Pre-conference courses and tutorials are filling up fast and are always a sellout. Register today to reserve your seat.

 

Register now!

SAS Enterprise Guide vs. SAS Studio

What’s the difference between SAS Enterprise Guide and SAS Studio? How are they similar? Just ask SAS’ Danny Modlin.

Find more tutorials on the SAS Users YouTube channel.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 11 replies
  • 1789 views
  • 0 likes
  • 5 in conversation