DOT.NET code again #xpa
Adrian Wick
Dear wizards.
can someone, for the love of God, explain to me how to code 3rd line of the following code in xpa (Controls.Add(simpleButton)). private void CreateSimpleButton(int left, int top) { SimpleButton simpleButton = new SimpleButton(); Controls.Add(simpleButton); simpleButton.Text = "Show Settings Page"; simpleButton.ImageOptions.ImageList = imageCollection1; simpleButton.ImageOptions.ImageIndex = 0; simpleButton.Padding = new Padding(10); simpleButton.AutoSize = true; simpleButton.Location = new Point(left, top); simpleButton.Click += SimpleButton_Click; } To me it looks like i need a Controls dotnet variable and add this button to the Controls. The button is on my form, but it has no text, no image, nothing ... I know its friday, but ... I hate it when someone shows only a part of the code and not everything ... Any info is appreciated! Adrian |
|
Frederik Soete
Hi there, TGIF. Not at all sure where you are going with that example, but you should know that "Controls" can be a member variable in e.g. a Form (window). You can identify or get a pre-existing Form via its (window/win32) handle, which you could get via Magic functions... Look those up in Magic help: handles exist for windows and controls. Actually a window is also kind of like a control... You can get a control through .Net Control.fromHandle(...). IIRC, you can assign and "cast" this value to a (Form) variable. Once you have a Form, you can access its Controls collection as needed. This is all just to give you ideas to look up, not fleshed out, but I hope you get sth. from this regardlessly... HTH, Dear wizards. |
|
Adrian,
Is there any particular reason you’re trying to create a dotnet button rather than using a button style already built into XPA? Might be going through extra work for no reason. A regular XPA button can raise an event that can call a dotnet system function.
Keith
From: main@magicu-l.groups.io <main@magicu-l.groups.io> On Behalf Of Adrian Wick
Sent: Friday, June 17, 2022 12:25 PM To: main@magicu-l.groups.io Subject: [magicu-l] DOT.NET code again #xpa
Dear wizards. |
|
Adrian Wick
@Frederik
thank you! @Keith no particular reason ... just trying to learn DOT.NET ... Regards A |
|
Adrian Wick
Found the solution in "3rd party dotnet samples".
Thank you! |
|
I really don't know what i was doing before that it didn't work ...
3 simple lines of code are all that are needed and a dot.net variable.
You guys just made my vikend :) Beer's on me! A |
|
Craig Martin
Vikend? You sound like you are channeling Pavel Chekov in Star Trek IV: The Voyage Home
"Excuse me, sir. Can you direct me to the Navy base in Alameda? It's where they keep the nuclear wessels"
Anyhoo.
The dot net snippets feature has limitations that will inflict undue pain on your future.
Best to build a dotnet exe or dll (better, a python script or python compiled exe) independent of Magic you can call.
This is not a "choose your own adventure" narrative. Thank me later.
From: main@magicu-l.groups.io <main@magicu-l.groups.io> on behalf of Adrian Wick <adrian.wick2015@...>
Sent: Friday, June 17, 2022 11:02 PM To: main@magicu-l.groups.io <main@magicu-l.groups.io> Subject: Re: [magicu-l] DOT.NET code again #xpa [Edited Message Follows] I really don't know what i was doing before that it didn't work ...3 simple lines of code are all that are needed and a dot.net variable.
You guys just made my vikend :) Beer's on me! A |
|
Good day to everoyne! |
|
Hi Adrian,
toggle quoted message
Show quoted text
With a .NET control you normally have the ability to set most of their properties on the form (just expand them) or change/add them manually. The 'Load event handler' would be the Task Prefix if you would do this manually. Also make sure you have the xxxxVisibily (and/ or the xxxxInitialVisibility) property set to at least Visible. Best regards, Harry Kleinsmit. On Sat, Oct 1, 2022 at 12:31 AM, Adrian Wick wrote:
|
|
Adrian Wick
I understand that.
How would you than call this line of code in xpa? this.Controls.Add(ribbon); Which variable do you use to replace *this.*? Regards A |
|
The 'RichEditControl' DevExpress variable.
toggle quoted message
Show quoted text
On Sat, Oct 1, 2022 at 09:03 AM, Adrian Wick wrote: I understand that. |
|
And than the ribbon is placed inside of the richeditcontrol 1st picutre:
|
|
Adrian Wick
Got it working!
richEditControl1.FindForm().Controls.Add(ribbon) FindForm() is the solution. Regards A |
|
Great! Thanks for the info/update!.
|
|
Adrian Wick
Hm,
i have a problem with System.Linq.dll. I have it in my crr, but when I try to use it in a .net variable, its not found. Even if I use invoke net I cant declare it as using System.Linq ... It is simply not there. Do you guys have the same problem? Regards |
|
Adrian Wick
FYI I needed to also add System.Core to the crr ... |
|