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,

Frederik Soete

Op vr 17 jun. 2022 18:24 schreef Adrian Wick <adrian.wick2015@...>:

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


Keith Canniff
 

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.

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


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!


Adrian Wick
 
Edited

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.

  1. DNSet(D.Text,'Test')
  2. DNSet(D.Image,DotNet.System.Drawing.Image.FromFile('Image.png'))
  3. DNSet(D.AllowFocus,'FALSE'LOG)
and than an event for D variable and "Click" action to do something when the button is clicked ...

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.

  1. DNSet(D.Text,'Test')
  2. DNSet(D.Image,DotNet.System.Drawing.Image.FromFile('Image.png'))
  3. DNSet(D.AllowFocus,'FALSE'LOG)
and than an event for D variable and "Click" action to do something when the button is clicked ...

You guys just made my vikend :)

Beer's on me!
A


Adrian Wick
 
Edited

Good day to everoyne!

It's me again with another dotnet c# puzzle. 

Task:
Use devexpress richtextedit control to edit docx, rtf, txt ... files. Displaying this control works like a charm. The problem is with ribbon.

Their example of the code for ribbon:
RibbonControl ribbon = richEditControl1.CreateRibbon(); this.Controls.Add(ribbon);

And for this. it says:
Use the RichEditControl.CreateRibbon() method overloads to add a ribbon to the RichEditControl at runtime. Paste this code to the form constructor or to the Load event handler.

The only way is to use the Load event handler i guess. Can someone explain to me how would i go and use Load event handler?

Oh. the problem is that ribbon come up empty! But it should have all the elements like in word ... If i replace this. with richtextedit control everything is as it should be, except for the part that the ribbon is
loaded inside of the richtextedit control and it cover the top side of the contorl ...



If i place the ribbon on the form as a separate control, the ribbon shows up, but its empty.


I look up the 3rd dot net samples and every "button" is placed on the ribbon by code ... I don't want to do that.

Regards,
A


Harry Kleinsmit
 

Hi Adrian,

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:

Good day to everoyne!

It's me again with another dotnet c# puzzle. 

Task:
Use devexpress richtextedit control to edit docx, rtf, txt ... files. Displaying this control works like a charm. The problem is with ribbon.

Their example of the code for ribbon:
RibbonControl ribbon = richEditControl1.CreateRibbon(); this.Controls.Add(ribbon);

And for this. it says:
Use the RichEditControl.CreateRibbon() method overloads to add a ribbon to the RichEditControl at runtime. Paste this code to the form constructor or to the Load event handler.

The only way is to use the Load event handler i guess. Can someone explain to me how would i go and use Load event handler?

Oh. the problem is that ribbon come up empty! But it should have all the elements like in word ... If i replace this. with richtextedit control everything is as it should be, except for the part that the ribbon is
loaded inside of the richtextedit control and it cover the top side of the contorl ...



If i place the ribbon on the form as a separate control, the ribbon shows up, but its empty.


I look up the 3rd dot net samples and every "button" is placed on the ribbon by code ... I don't want to do that.

Regards,
A


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


Harry Kleinsmit
 

The 'RichEditControl' DevExpress variable.


On Sat, Oct 1, 2022 at 09:03 AM, Adrian Wick wrote:
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


Adrian Wick
 
Edited

And than the ribbon is placed inside of the richeditcontrol 1st picutre:
- which makes the ruler  over the ribbon and it looks like the ribbon is cut off and
- the ribbon is placed over the top part of the richeditcontrol papper

The ribbon needs to be added to the form and not the richeditcontrol ...

Based on your screenshot, it looks like Ribbon Control is added to the Controls collection of RichEditControl.
Please make sure that you are adding Ribbon Control to the parent form's Controls collection, not RichEditControl's.


Adrian Wick
 

Got it working!

richEditControl1.FindForm().Controls.Add(ribbon)

FindForm() is the solution.

Regards
A


Harry Kleinsmit
 

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 ...

Its working now.