.NET Tutorials, Forums, Interview Questions And Answers
Welcome :Guest
Sign In
Win Surprise Gifts!!!

Top 5 Contributors of the Month
david stephan
Gaurav Pal
Post New Web Links

UserControl + StatusBar + backgroundworker

Posted By:      Posted Date: October 22, 2010    Points: 0   Category :Windows Application

Hi all,

i have got a problem while studying with Usercontrol and statusbar. That is that I have got a main form,a status strip with toolsstrip progressbar and some Usercontrols. I use UserControl like a form. i have got one UserControl for each form.On each userControl, I have got some components- buttons,labels, one datagridview.And there is a menu panel on my mainform that is about UserControl calling links.When I press a link on this menu panel,I want to call one of this UserControl and load my datagridview while my Usercontrol is loading.I saw many articles and forums posts about "backgroundworker" component.I tried to implement with my main form to do thing that I aimed.But, it gives me an error.i couldn't understand too much.i designed my UserControl with .NET components.My mainform codes are below about backgroundworker component:


//my public variables each usercontrol instances to use from my ShowPanel() method

        public ucMemberList ucMList = new ucMemberList();

        public ucRecordList ucRList = new ucRecordList();


         private void xplMemberList_Click(object sender, EventArgs e)



View Complete Post

More Related Resource Links

UserControl like asp:Panel


Is it possible to write own User Control with functionality like asp:Panel?

UserControl, CustomControl Design Time Support errors IOC, Dependency Injection, MVP

  Hi, is there a way to completely disable design time support for CustomControl, and UserControl ? I have about 30 UserControls and 10 CustomControls in my WinForms app, which contains some Dependency Injections and IOC stuff in constructors and Load handlers. I have lots of large UserControls containing smaller UserControls (CompositeView). All my UI code is pretty dynamic and the only thing i need to do at design time is to drag&drop containers in other containers (UserControls). And now i have a hard time doing this, because i have to wrap all constructors and Load Handlers in CurrentProccess!="devenv"... and when I'm Implementing some new View interface (which consist lots of properties) in UserControl all those properties by default throw NotImplementedException and i don't always need to implement them immediately but still i need to be able to run this code for testing. Besides, then i have to clean up designer generated class because it adds unnecessary null value property initializations, and then it way add some other ____ code, and so on.... Imagine UserControl with 10-15 nested UserControls, and then i try to open it in Form Designer and get ObjectReference NULL exception (for IOC) or some NotSupported NotImplemented exceptions (for properties) without adequate CallStack available! There is a CallStack but there is no trace in it to my Code (

How to load a usercontrol xaml at runtime ???????

Hi, I have a usercontrol xaml created in Expression Blend. Similarly i have xaml for other usercontrols as well. Now i want to draw these controls at runtime on click of buttons, the way it works in VS IDE (Toolbox and Drawing area) Is there any way to load such usercontrols on Canvas at runtime ? What would be the best way to load controls at runtime ?      Programmer

Using an Application Resource in Nested UserControl

Hello This problem has been niggling me for months and I just can't seem to get to the bottom of it. I have a UserControl, let's call it 'UC_List', and the ListBox in it uses a Style which I have declared in my Application.xaml file. When working with UC_List.xaml everything seems fine. I then place 'UC_List' into a UserControl, let's call it 'UC_Summary'. I have declared the namespace at the top of UC_Summary.xaml. The xaml code in UC_Summary now has an Error: Could not create an instance of type 'UC_Summary'. Now I cannot see anything in the Design window, only a warning saying 'Problem Loading, the document contains errors that must be fixed...' However when I run the application everything works fine! After a lot of trial and error I found that the cause of the problem seems to be the Style referenced in the Application.xaml. If I declare the Style in UserControl.Resources at the top of UC_List the error goes away and the graphics in UC_Summary return. I've so far duplicated my Styles into individual UserControls to work around the problem but this could easily lead to inconsistancies. If anyone can suggest anything I would be really pleased to try it. Thank you. Regards Chris

Property of a base UserControl it's not handled correctly

Hello,I have a class that is a base class for my server controls. Inside this class I have a property that can take values from an enumeration.public enum PanelModeEnum { Add = 1, Edit = 2, ReadOnly = 3 } public class BaseControl : System.Web.UI.UserControl { #region Event Handling Management #endregion public PanelModeEnum PanelMode { get; set; } public virtual void ChangePanelMode(PanelModeEnum newMode) { this.PanelMode = newMode; } } I have then several user controls that inherits from this BaseControl and that I add into aspx pages declaratively<gsl:PhoneNumberUC ID="ucPhoneDetail" runat="server" PhoneNumberType="Home" />I would like to show one the derived BaseControl classes inside a ModalPopupExtender using server-side code. Before doing this I call the ChangePanelMode with a value from the PanelModeEnumucPhoneDetail.PhoneNumberType = ptype; ucPhoneDetail.ChangePanelMode(PanelModeEnum.Add); this.mpePopupPhone.Show(); But when, inside the inherited user control I check for the PanelMode property likeif (this.PanelMode == PanelModeEnum.Add) { ... } the value of this.PanelMode is always equal to zero. Why?Kindly regards

Detect Deactivation of Usercontrol

Hi All, I have added a popup type usercontrol to a form which I call like this: MyUserControl = New AdvancedControl MyUserControl.StartPosition = FormStartPosition.Manual MyUserControl.TopLevel = False MyUserControl.Location = Me.Parent.PointToScreen(New Point(Me.Left, Me.Bottom)) ParentForm.Controls.Add(MyUserControl) MyUserControl.Show()  How can I detect when a user clicks somewhere other than the usercontrol and then dispose of the usercontrol.  The lost focus and deactivate events dont seem to fire. Thanks

usercontrol used in datagridviewcell

Dear Programmers, Im trying to create a user control above to be used inside a datagridviewcell this user control, has a button and a textbox. Used for lookup it loads a form the user choose the row and the record id or primary key is loaded to the uercontrol textbox. the variables are now private static, but when i have 2 usercontrols in the same datagridview, the values are the same. And when i change the properties variable from static to nonstatic public variables. the variable values are not seen and the control dont work. I will upload the classes below. I appreciate your help.<pre lang="x-c#"> namespace x { public class DataGridViewButtonTextBoxColumn : DataGridViewColumn { public DataGridViewButtonTextBoxColumn() : base(new DataGridViewButtonTextBoxCell()) { //base.DefaultHeaderCellType = typeof(DataGridViewTextBoxCell); //base.SortMode = DataGridViewColumnSortMode.Programmatic; } public override object Clone() { DataGridViewButtonTextBoxColumn Column = (DataGridViewButtonTextBoxColumn)base.Clone(); Column.DBName = this.DBName; Column.ComboLup = this.ComboLup; Column.PrimaryKeyField = this.PrimaryKeyField; Column.PrimaryKeyField2 = this.PrimaryKeyField2; return Column; } public override DataGridViewCell CellTemplate { get { return

Nested controls in UserControl return null (FindControl)

Hi everyone, I have a very weird issue. I have a UserControl that has some controls inside. I want to refer those controls after, in another postback. But when I try to get them the ".Controls" property of my controls returns null. I'm working on vs2008 Here is the sample code: public partial class MyUserControl : System.Web.UI.UserControl { protected void Page_Load(object sender, EventArgs e) { foreach (Control control in this.Controls) { Response.Write(control.ClientID); } } private void MyTable() { Table table = new Table(); TableRow row = new TableRow(); TableCell cell = new TableCell(); CheckBox check = new CheckBox(); check.ID = "theId"; check.Text = "My Check"; check.AutoPostBack = true; cell.Controls.Add(check); row.Cells.Add(cell); check = new CheckBox(); check.ID = "theOther"; check.AutoPostBack = true; check.Text = "My Other Check"; cell = new TableCell(); cell.Controls.Add(check); row.Cells.Add(cell); table.Rows.Add(row); this.Controls.Add(table); } protected override void Render(HtmlTextWriter writer) { MyTable(); base.Render(writer); } } And in the Default.aspx is like:<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="Default.cs" Inherits="Tester.Default" %> &

UserControl with a control property?

Hi... I have defined a UserControl wich needs to reference another control like this: <ctrl:Cook TheList="listView1" DefaultFileName="MyRecipe"></ctrl:Cook> The code behind of the control has the property defined:         public ListView TheList { get; set; } But I have a runtime error saying: 'ListView' type does not have a public TypeConverter class. And in design time I get: Property TheList of type ListView cannot be specified as string.   I know WPF is trying to read a string instead of a ListView, but dont know the magic solution. Maybe a converter? Please suggest the simpler solution you can, because this is not a vital requirement on the app. Thanks in advance for any help  

How to set Panel.Zindex value though XAML code if any of the Grid/UserControl children having the fo

Hi, I have a Grid with 10 buttons. If any of these buttons has focus then I want to set the Panel.Zindex = 999 for the Grid. How to do this in XAML code?Please remember to click "Mark as Answer" on the post that helps you, and to click "Unmark as Answer" if a marked post does not actually answer your question. This will help other members to find the solution easily.

Usercontrol, in master page, calling a method on the main page?

I have user control called 'Header.asxc' that is registered in my master page. That user control has an image link. The clicking of this link needs to cause a dropdown on the main page to repopulate. I am comforable with delegatges, with populating the dropdown etc... My problem is I cant find the usercontrol from the page, in order to set the function event. I got this work previously when the user control was registered on the page in question but this case with the master page  has me confused. Here is a summary of the set up. 1. I put this in the Header.ascx usercontrol that is registered by the Master page. public Delegate locReloadCompanyDropdown;2. Further down in that page in the relevent _Click event, I put this. locReloadCompanyDropdown.DynamicInvoke();3. Back in the main page I declared these.. public delegate void reloadCompanies(); private event reloadCompanies doReloadCompanies;4. Finally I try to set the delegate doReloadCompanies += new reloadCompanies(PopulateCompanyDropdown); //Page.Header.locReloadCompanyDropdown = doReloadCompanies; //Header.locReloadCompanyDropdown = doReloadCompanies;You can see a couple of attempts I have made remarked out in the code above. Neither work. What am I missing here? Thanks all.  

UserControl content generated from XML?

I am trying to generate items in wrappanel defined in XML. I am missing something here. I got to the point where I can generate content from xml but it is duplicated. With the code below, I am getting 3 stackpanels with the same content. How to pass the the other two Person nodes from XML? Thank you in advance. XML: <?xml version="1.0" encoding="utf-8"?> <persons xmlns=""> <Person> <FirstName>AAAA</FirstName> <LastName>AAAA</LastName> </Person> <Person> <FirstName>BBBB</FirstName> <LastName>BBBB</LastName> </Person> <Person> <FirstName>CCCC</FirstName> <LastName>CCCC</LastName> </Person> </persons> <p style="margin:0in 0in 10pt"> </p>  XAML: <Window.Resources> <XmlDataProvider x:Key="DashboardData" XPath="/" Source="Data/Dashboard_DataSource.xml" /> </Window.Resources> <Grid x:Name="LayoutRoot"> <UserControl> <!-- local:UserControlWP/ --> <ItemsControl x:Name="list" ItemsSource="{Binding Source={StaticResource DashboardData}, XPath=persons/Person}"> <ItemsControl.ItemsPanel> <ItemsPanelTemplate> <

Is it possible to put usercontrol in a menuitem?

I have a calendar usercontrol that I would like to put as a subitem of a menuitem. Is this possible? A c# example would be helpful if anyone knows the answer to this.   Thanks!

usercontrol layout in canvas at runtime puts in mult. copies of 1st element in collection.

I created a usercontrol which has a few DP's that match up with fields in a sql table. The requirements of this control specify if I get a specific status value I will flash the usercontrol to draw attention to a specific area of equipment in the facility. I also provide a tooltip which has all the fields of data to view. The usercontrol should only display it's description. On a button click I run the following code which instantiates a new observablecollection of my custom usercontrol (I call it profiNode). It then fills a dataset by calling our DAL and then I loop through the datarows using the values to create a new profiNode object for each row. I then add these to the observable collection, but I suppose a generic list would work too.     ProfiNodes = new ObservableCollection< profi.profiNode > (); DataSet data = new DataSet(); data = this.DataLayer.getDataSet("Select * from ProfibusMapping", CommandType.Text, null); foreach (DataRow row in data.Tables[0].Rows) { profi.profiNode node = new profi.profiNode((string)row.ItemArray[0],(int)row.ItemArray[1], (int)row.ItemArray[2], (int)row.ItemArray[3], (string)row.ItemArray[4], (DateTime)row.ItemArray[5], (int)row.ItemArray[6], (int)row.ItemArray[7], (string) row.ItemArray[8], (double)row.ItemArray[9], (double)row.ItemArray[10]); node.ID = string.Format("node_M{0}_A{1}&q

Nested UserControl Render Order

I have a custom control created in codebehind, and I have in the same control an ordinary asp.net button. Like this: protected void Page_Load(object sender, EventArgs e) { } private void MyTable() { Table table = new Table(); TableRow row = new TableRow(); TableCell cell = new TableCell(); CheckBox check = new CheckBox(); check.ID = "theId"; check.Text = "My Check"; check.AutoPostBack = true; cell.Controls.Add(check); row.Cells.Add(cell); table.Rows.Add(row); this.Controls.Add(table); } protected override void CreateChildControls() { MyTable(); base.CreateChildControls(); } And in the asmx something like this:<%@ Control Language="C#" AutoEventWireup="true" CodeBehind="MyUserControl.ascx.cs" Inherits="Tester.MyUserControl" %> <asp:Button ID="Button1" runat="server" Text="Button" /> ok... now. When I render my control it looks like: [BUTTON] [ ] My Check But I really need that the button render after the checkbox. Any idea how can I do that?

Load .net UserControl using jquery and httphadler

I want jQuery to load a usercontrol dynamically from server side code. i want that thing using httphandler.i heard this thing some where but i didn't get any example plz help me to complete this task 

Ajax control with usercontrol

Hi all, Can I point some properties (like targetcontrolid and CancelControlID) from ajax controls to a panel that is in a usercontrol file ? For example: aspx file<asp:modalpopupextender id="mpeRegistroAlterado" runat="server" TargetControlID="cmdInvisible" CancelControlID="cmdClose" popupcontrolid="Panel_Msgbox_Timestamp" popupdraghandlecontrolid="PopupHeader2" backgroundcssclass="Fundo_Ao_Exibir_Painel" > </asp:modalpopupextender> ascx file<asp:Button ID="cmdInvisible" runat="server" Text="Button" CssClass="Esconde" /> <asp:panel id="Panel_Msgbox_Timestamp" style="display: none" runat="server"> <div class="Div_Painel_MSGBOX"> <div id="PopupHeader2" class="Div_Painel_MSGBOX_Cabecalho">System</div> <div class="Div_Panel_MSGBOX_Body"> <br /> <br /> Message.<br /> <br /> <br />   </div> <div class="Div_Painel_MSGBOX_Buttons"> <input id="cmdclose" type="button" value="Close&q
ASP.NetWindows Application  .NET Framework  C#  VB.Net  ADO.Net  
Sql Server  SharePoint  Silverlight  Others  All   

Hall of Fame    Twitter   Terms of Service    Privacy Policy    Contact Us    Archives   Tell A Friend