Wpf - Custom Control Can Only Be Instantiated Once?
Mar 8, 2012
I am new to WPF and custom controls.I have implemented a custom control in VB with WPF and MVVM based on Davids example: [URL]..I have a custom control libary and a reference to my project to implement my control.I implement my contol in the View via XAML:
I am trying to create a new thread that will import from an excel spreadsheet, because it was doing all the import before the form actually displayed to the screen. So the user never saw the form while it was importing..In the form's load event I create the thread and start it, but I get this large error:An error occurred creating the form. See Exception.InnerException for details. The error is: ActiveX control '8856f961-340a-11d0-a96b-00c04fd705a2' cannot be instantiated because the current thread is not in a single-threaded apartment.
I am using visual studio 2005 pro on Vista Business?
how to specify a custom icon for display in the toolbox window when you create your own custom control? Something other than the dreaded "gearbox" icon.
I have an ASPX Custom Control which is supposed to load it's properties into an internal collection (defined with PersistenceMode.InnerProperty). Here's the ASPX
I am using custom textboxes and I need to be able to set the Text on txb1 based on the Text of txb2. I have simplied my code to the following:
Public Class customtextbox Inherits TextBox Public Event ControlReset()
[Code]....
So, when txb1 looses focus, if its Text is "fried", then it sets off txb2's ProcessAlert function. I had tried to change the value of txb2 Text in ProcessAlert function, but didnt work, so I tried to get it to raise an event instead, which then tries to set the Text property. However I still cant set txb2's Text property. The Text property seems to be set for the duration of the "life" of the Event handler. When I step through the forms controls within the Event handler, the changed Text value is there, but not outside of the Event handler.
I've created my own ascx control with button inside it. Now I'm using this control inside other control. (In my case it is a webpart). What I would like to do is program button.click logic from my custom control inside webpart
Can a custom control NEW Sub be the only one that executes when Inheriting from an existing control please?I am Inheriting from TabControl and I do not want the base New Sub called, is this possible?In other words, I do not want TabPage1 and TabPage2 to be added.A Form has an Activated Sub which runs once a Form is activated.It is a pity that Microsoft have not got such a method in the baseControl Class otherwise I could have used it within a custom TabControl.
Public Class Form1 Private Sub Form1_Activated(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Activated End Sub
We have a ASP.NET web application written in VB.NET where we build content programmatically during the Init event.We make extensive use of user controls, building them on the fly, and I now want to start including SilverLight content.Is there an easy way of embedding a SilverLight application in a control, and then instantiating the whole thing in code, in the same way as you'd programmatically add ordinary ASP.NET controls to a page?The SilverLight component itself works fine when added to a page using the <object> tag but I really want to be able to reuse it elsewhere in code.Since I'm expecting use of SilverLight to increase in our application, and the asp:Silverlight control seems now to be deprecated, I'm looking for an alternative way of wrapping the content.
What I've done is create a User Control Library (Project) and I've added a single User Control to that project. The control contains a single FlowLayoutPanel, and I created a Property on the control itself to pass the FlowDirection from the Control to its FlowLayoutPanel child.
Build, reference, component appears in the Toolbox and everything works fine, but the property on the control does not appear in the Properties window when I go to edit it at design time.
I create an Instance of Access to view a report through my app.I would like to check if an Instance of Access has either already been opened by the user, or by the app. If so, use that instance.
Dim oAccess As Access.Application Public Sub CreateAccessInstance() Try[code]...
As it stands now, It creates multple MSACCESS.EXE processes which are running until I exit the app.
I think I just need a push in the right direction. I cannot seem to get my sub from an instance of my class, once instantiated, to run when I click on the button. My Code in the class is
When I click this:Private Sub btnBark_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnBark.Click mydawg.bark() End Sub
When developing a Windows Forms Application, I can see in the Application.Designer.vb file where Me.MainForm = Form1, but I can't find where/how Form1 actually gets newed-up.
Is it possible to change the upperbound of an array once it has been instantiated? I want to change the upperbound in an array so it matches the number of items that hold a value.
I have a customer intranet (ASP.NET / VB) thats instantiating an asp.net session checking various things in the dblogin process. The Intranet has various sub-systems.The marketing sub-system requires an app_role to be assigned to the Intranet user for them to view the section.I need to create a new booking form for this section but the code appears to use a generic form which is use throughout the site in various other sections. So its not a good idea to ammend what is currently there.Create a new application in C# / ASP.NET and also in IIS. (rather than a new site, create an app within the Intranet site in IIS)Will I be able to check for the session thats currenting set in the cookie?If the session is open then the user is able to see the Intranet and I assume I will need to do some checks for the app_role too.I am simply going to put the URL for the app in the menu for marketing and then do another check just incase someone gives the URL to someone who doesnt have access to the menu.Will i be able to check and use the cookie thats been instantiated by another application?
Can you raise events from a class that has only shared members and doesn't get instantiated? I originally had the class members non-shared and created instances of the class where I need them. I had the events being raised and everything worked as expected. But as the class members are actually application level and do not need instancing, I converted all members in the class to shared so they could be accessed from anywhere in the program without creating an instance of the class. But WithEvents requires the creation of a class instance. I've done that and it seems to work fine when using an instance. And since I need the events handled in only one class, I can create the instance in that class and let all other areas access the class directly, without creating an instance.
I have a .Net 4 WinForms app that generates a DLL, calls CreateObject on the generated DLL then calls one of several methods that the DLL contains. The DLL is eventually used by a separate app. This WinForms app is just to generate and test the DLL hence why it can generate the DLL multiple times.The problem lies in the fact that calling CreateObject on the DLL locks the file to the process. The next time the DLL is generated it can't overwrite the previous DLL file on disk without closing the app completely and starting it again.
I've tried Marshal.ReleaseComObject, executing the CreateObject in a separate AppDomain, even setting the variable holding the COM object to a different COM object via CreateObject, manually calling GC.Collect() and a whole host of other things but none result in unlocking the file.The code flow is basically (simplified and generic names, etc.):
... ' Compile and generate DLL that is COM enabled and works fine ... Dim foo As Object = CreateObject("Bar.Foo")
[code]....
is there a way to release a file lock on a COM DLL that has been instantiated via CreateObject without killing the process?
Note: this is a continuation of this original issue. I now have the DLL registering without locking the file but now the issue is with the CreateObject call not the DLL registration.
This is a question I have asked myself many times in the past as I nested using statements 5 deep. Reading the docs and finding no mention either way regarding other disposables instantiated within the block I decided it was a good Q for SO archives.
This runs correctly, but Excel remains active after close.
If I don't create the range objects below, everything seems to work (with no output of course). Does anyone have any idea on how to keep Excel from staying in memory. Also... in the tests I'm running, I do not make the application visible.[code]...
I have created a simple custom control - we will call it a "panel with buttons". Here is how I instantiate it:
[Code]....
So what I wind up with are multiple instances of my panel. Each of these panels has a button on it called Button1. My question is - how do I capture this button event in a way that I will know which panel index it came from?
In the custom control there is only the Button1_click event - and when I click on it in any of the multiple panels I manually instantiated the event does occur, but how I can tell which one of my instantiated buttons were clicked...
I am working on an application that requires buttons and links to be added during run time, it's a bit like a flow chart. The buttons are used to display information similar to a multi line text box, but I also use the click, double click and mouse events for these buttons. The links are drawn as label controls. My problem is that I want to control the format order of these controls with the buttons always being on the top layer and the labels one layer back so that when labels are added they aways pass behind the buttons. If this was done at design time it is very easy to use the menu Format > Order to get overlapping controls displayed the way I want. But, the controls placed on the form at run time do not have a Format or Order property.
I am trying to make a listview custom control based on the standard listview control that will allow me to drag a column header outside the standard listview control and drop it on a panel. I plan to use the drop event to determine which column I should group by view on.
[URL]I tried dragging it but it didn't work. I'm not used to the IDE. Also, how would I make that control at runtime and place it on the form I understand you would do
I can make this without a dll file, also inside a normal project, making a class for it and inheriting the desired base control class, compiling the project and the toolbox has the custom control.
But now I want to make it in a separate file, in a dll file. I use vb express 2008.
I start a new class library project, add the reference System.Windows.Forms to the project and add this code (this is only an example):
Inherits System.Windows.Forms.Button Private Sub New() Me.Backcolor=Color.Red End Sub
I compile the project and get the dll file. Then I add this file to the toolbox, but I get the error message: "this control has no components."
I'm trying to play with this: [URL]..I have no clue how to use it though.What i THOUGHT i had to do was open the project and "build" it to produce a .dll or something which i would then add as a reference in my new project. I'm unable to open the solution so i could not test this theory.
Im trying to add a custom combobox to the database, the problem is i cant figure out how to do it. This combobox has images in it, i had to find the code to put the images in it cause the .net framework does not support icon's in combobox's. here is the code i found, cant remember where i got it, i think from code project.
I have created a custom class, which contains a panel and a label on it. I added to this class a pcaption property, which holds the label text. This property is browsable and I can change its value.But when I drag the custom control to the form and change the pcaption property, it has no effect. Even the <Defaultvalue> has no effect. Why?
Here is the class code:
Imports System.ComponentModel Public Class mypanel Inherits Windows.Forms.Panel Private panelcaption As String