First of all, thank you all who attended my session today. It was a lot of people in the room, and with the competition from Microsoft talking about a very hot topic in the other, bigger room, I really wouldn’t expect to see all of you there. I hope you found the things you saw useful, and that you’ll take advantage of all the free stuff that I am posting today here on Vjeko.com.
This time I’ll split it up in different files, to make it more manageable.
Tweaking Page UI
First things first, so I start with the new “Semi-transparent Borderless Draggable Styleful Standard Dialog” page type, which in fact is not a page type but a control add-in that abuses the openness of .NET Framework to the fullest. If you have not been at the presentation, this is what it looks like:
And yes, it really is a page object. And it’s an extremely simple trick. You only need to call the FindForm method on the control you instantiate, and then you can do whatever you would normally be able to do with a System.Windows.Form object. Make it semitransparent. Hide the borders. Paint it in pink or something.
The code is ugly, completely optimized, dumped with a shovel and then mixed and stirred with a bazooka, it was written for the better part of it at 2 o’clock in the morning, but it proves the point. I am thinking of providing a framework which would allow you to do all those things in a more proper way that I wouldn’t be ashamed to put here, as I am to put the stuff that I’ve just put.
You can download this demo here: https://vjeko.com/wp-content/uploads/2014/11/VjekoCom.FormTweaker.zip
Drag & Drop, and BingMaps Add-ins
Then we have the Drag and Drop demo, and the BingMaps demo. I have reused my own code from earlier, so I am simply linking back to the previous demo: https://vjeko.com/blog/directions-emea-2014-content
About the Drag and Drop thing, feel free to use it as you like, and about the BingMaps demo, most of the code in there comes from Microsoft’s own blogs and demos, and I am pretty sure you are okay to reuse it as you like.
Auto-Register For Control Add-ins
The next on the list is the auto-register utility. It taps into Codeunit 1, automatically registers the add-in in the Client Add-ins table, and also automatically downloads the resource from your URL if it’s not present in the Client Add-ins. This makes sure that the control is always in place when you run an object that uses it.
Download the bits here: https://vjeko.com/wp-content/uploads/2014/11/AutoRegister.zip
Visual Studio Templates
You install the templates simply by copying them to your Documents\Visual Studio 2013\Templates\ProjectTemplates folder.
Download the simple template here: https://vjeko.com/wp-content/uploads/2014/11/Microsoft-Dynamics-NAV-2015-Simple-Extensibility-Control.zip
Download the advanced template here: https://vjeko.com/wp-content/uploads/2014/11/Microsoft-Dynamics-NAV-2015-Advanced-Control-Add-in.zip
This advanced template is obviously work in progress, there are so many more things to be added to it, and I hope, I just hope this time it doesn’t remain at “if I have time I’ll build on top” as it happened with so many good and useful stuff I have here, and that I really turn this into a decent framework, worth sharing on CodeProject, or GitHub. or if I really have time, on NuGet.
And this last part is available here: https://vjeko.com/wp-content/uploads/2014/11/Extensibility_Test_Page.zip
That’s All, Folks…
Once again, thanks for joining my session. Please let me know if you found it useful, and if any of this content and demos helps you in your everyday work.
See you in the cloud, and definitely next year in Antwerp again!
This Post Has 15 Comments
This is very handy to make a fixed screen when needed.
Would this also be possible with WPF form stuff you think?
(Maybe you have also an example of this :-))
No, I don’t have an example of WPF, but you can make a WPF container in windows forms, and then do whatever you like with it. The point here is – it’s all just a Windows Forms application, just like any other.
When I try to import the AutoRegister.fob, I get an error message saying: “Codeunit 9701 does not exist.”. Any idea why and how to fix this?
Are you using NAV 2015?
No, I was using 2013. Switching to 2015 should fix it then?
Yes, this demo code is all in NAV 2015.
Hi Vjeko, did you tried to change the color of a field with your Tweak UI in a repeater? I played with it (special thanks for this!!) and had the possibility to change the color of the cell Im in (with CellEnter Event) but not if its ReadOnly and not if im not in the cell. It feels NAV overwrites my settet color all the time 🙁
Some of my customized code:
private void SetControlBackColor(Control control, Color color)
if (control.GetType() == typeof(Microsoft.Dynamics.Framework.UI.WinForms.Controls.BusinessGridView))
BusinessGridView myBusinGridView = (BusinessGridView)control;
myBusinGridView.BackgroundColor = Color.Blue;
BusinessGridView BG = (BusinessGridView)control;
BG.CellEnter += BG_CellEnter;
catch (Exception e)
MessageBox.Show(“~~” + e.Message);
and the Event:
void BG_CellEnter(object sender, DataGridViewCellEventArgs e)
BusinessGridView BG = (BusinessGridView)sender;
DataGridViewCellStyle myCellStyle = new DataGridViewCellStyle();
myCellStyle.BackColor = System.Drawing.Color.Red;
myCellStyle.Alignment = DataGridViewContentAlignment.TopRight;
myCellStyle.ForeColor = Color.White;
Kind regards, Matthias König
No, sorry, I really don’t have any off-the-top-of-my-head ideas.
Hi Vjeko, I would like to use the control addin but with a WPF UI. As I recall you told me that this is possible , but do you have a small “getting started” example somewhere ?
Hi Krisje! I don’t have a working example – I have never done it myself, but I have seen people do it many times in NAV. Maybe this could get you up and running: https://msdn.microsoft.com/en-us/library/ms742215(v=vs.110).aspx
I will try this example, looks promising :).
Hi Vjeko, I have another question about the Tweaker 🙂
I want to color only some of the fields. With control.AccessibleName I have the possibility to know which caption the control has and identify if I want to color this. I would rather do this with the control ID? Is there a possibility to get access to the NAV properties like Control ID? With EllipsisTextBox I can not reach this :/
I don’t know of a way to do that, sorry 🙁 As far as I could figure out, I don’t think these properties are exposed in the UI layer. I feel that the mapping between NAV control IDs and what’s visibile in the RTC object model is managed by the NST.
thats a pity. But then I handle it with the caption 🙂 thanks!
… meanwhile two years later…
With our current NAV Version we do not know in the CAL Code if an field its editable or not.
In my case, I want to know it without an extra variable for every field. And we do not have a “Field Metadata ” Table.
Now I thought about this little helper here and find a strange way over “AccessibilityObject.State” of the found field.
The “ReadOnly” and “Editable” properties are not used (if I see this correct). But if I want other properties its very complicated to search the correct one. Did you (or one of the other readers) how to solve that? An easy way to serialize that? Or any other Ideas how to “hack” that?
(P.S. I hope its not totaly wrong to ask that here :D)