|
Hi all,
Thanks for your suggestions.
In fact I am new to web programing. I was wondering if we could download through the browser then why not through myown application.
I just want to avoid the windows progress bar while downloading. And also specify certain urls and forget about it. These will be automatically downloaded to the specified folder. Cool ! right ?
Thanks again
Regards
Shiraz
The Best Relligion is Science.
Once you understand it, you will know God.
|
|
|
|
|
Downloading has nothing to do with the "browser". You download things from web sites - or just about any remote machine through TCP/IP via sockets.
You can download files without any progress at all. Read about the WebRequest and WebResponse classes, as well as their derivatives like HttpWebRequest and HttpWebResponse . You can also use the easy-to-use WebClient class to download files.
All these classes includes examples in the .NET Framework SDK which was installed with Visual Studio .NET or standalone, however you obtained it. We have also discussed this many times in the past on this forum, so if you want to learn more, click "Search comments" above, but you should read the .NET Framework SDK documentation for those classes and their members first.
This posting is provided "AS IS" with no warranties, and confers no rights.
Software Design Engineer
Developer Division Sustained Engineering
Microsoft
[My Articles]
|
|
|
|
|
My application goes throught multiple database access.
during this time, the application is frozen since all its resources are dedicated to the task at hand.
Can anyone tell me how, or preferably point me to a tutorial that would explain to me how to connect to a database without freezing the main application screen?
Thanks in advance,
Jon G
www.Gizmocoder.com
|
|
|
|
|
You need to check into threading, this way you can execute your heavy processing on a separate thread from the main UI thread. I'd recommend you start with the Threading Tutorial[^] from the C# Programmer's Reference.
- Nick Parker My Blog | My Articles
|
|
|
|
|
|
Hi All,
I have created a class that simulates a MDI form by putting the 'child' inside a panel located in the 'parent' form. I had to do this because we use a custom UI that doesn't work properly with standard MDI forms.
The constructor of the class is something like
SemiMDI(System.Windows.Forms.Form client,System.Windows.Forms.Panel parentArea)
So far I've managed to create the form in the designed area and it works ok. Now the problem is when the parent form's resize event is triggered. I know it could be possible to resize the child by calling a 'rearrange' method in my class, but I would like to do it by subscribing the SemiMDI class to the 'resize method of the parent, so everytime I use my class I dont have to worry about linking the child form to the resize event of the parent.
Any ideas? Subscribing events is what I thought, but I'd like to know if you have a better solution.
Thanks!
|
|
|
|
|
In order to attach a handler, you would have to cast client to your Form type and make sure the handler is accessible (i.e., not private - use internal , perhaps).
When handling events in controls and forms, however, it's better to override the event handlers that are already present. So, if you needed to handle the Resize , it's better to override OnResize :
protected override void OnResize(EventArgs e)
{
base.OnResize(e);
} This has less overhead and gives you a greater amount of control over what happens when an event is fired (because your override is actually called before firing the event; calling base.OnEventName is what eventually may fire the event).
With this in mind, you might consider extending all your MDI child forms from a single class that implements this resizing behavior. That would be a good object-oriented design.
Even if this single base class must delegate resizing code to its MDI parent (perhaps the MDI parent contains information that the MDI children can't access), you must still make sure that the handler is accessible and implementing this code in a single base class makes for a better OO design.
This posting is provided "AS IS" with no warranties, and confers no rights.
Software Design Engineer
Developer Division Sustained Engineering
Microsoft
[My Articles]
|
|
|
|
|
Thanks. Its fixed and working now
|
|
|
|
|
Hi All,
I have created a class that simulates a MDI form by putting the 'child' inside a panel located in the 'parent' form. I had to do this because we use a custom UI that doesn't work properly with standard MDI forms.
The constructor of the class is something like
SemiMDI(System.Windows.Forms.Form client,System.Windows.Forms.Panel parentArea)
So far I've managed to create the form in the designed area and it works ok. Now the problem is when the parent form's resize event is triggered. I know it could be possible to resize the child by calling a 'rearrange' method in my class, but I would like to do it by subscribing the SemiMDI class to the 'resize method of the parent, so everytime I use my class I dont have to worry about linking the child form to the resize event of the parent.
Any ideas? Subscribing events is what I thought, but I'd like to know if you have a better solution.
Thanks!
|
|
|
|
|
DataSet ds = GetValues("tbl_Users_StoreID");
ddlStores.DataBind();
This I cannot do.
Because GetValues if of type SqlDataReader
and the ddlStores databind() also?
Here is the new code.
But nothing gets populated.
<br />
<%@ import namespace="System.Data" %> <br />
<%@ import namespace="System.Data.SqlClient" %> <br />
<%@ import namespace="System.Text" %> <br />
<%@ Register TagPrefix="mspos" TagName="footer" Src="~/Engine/Controls/footer.ascx" %> <br />
<%@ Register TagPrefix="uc1" TagName="header" Src="Engine/Controls/header.ascx" %> <br />
<br />
<HEAD> <br />
<title>Users Interface to Managing Adminitrators</title> <br />
<meta content="True" name="vs_snapToGrid"> <br />
<script language="C#" runat="server"> <br />
<br />
private DataSet ddlDataSet1 = new DataSet(); <br />
private DataSet ddlDataSet2 = new DataSet(); <br />
private DataSet ddlDataSet3 = new DataSet(); <br />
private SqlConnection myConnection = new SqlConnection("server=(local);database=MSPOS;uid=sa;pwd="); <br />
<br />
<br />
protected void Page_Load(object sender, System.EventArgs e) <br />
{ <br />
if (!Page.IsPostBack) <br />
{ <br />
BindData(); <br />
<br />
} <br />
} <br />
<br />
<br />
<br />
<br />
<br />
private DataSet GetStores() <br />
{ <br />
const string strSQLDDL = @"SELECT StoreID, Store FROM tbl_Users_StoreID ORDER BY Store"; <br />
SqlDataAdapter myDataAdapter = new SqlDataAdapter(strSQLDDL, myConnection); <br />
myDataAdapter.Fill(ddlDataSet1, "ddlStores"); <br />
return ddlDataSet1; <br />
} <br />
<br />
<br />
<br />
private DataSet GetAccessLevels() <br />
{ <br />
const string strSQLDDL = @"SELECT t.AccessLevelID, p.AccessLevel From tbl_Users t Inner JOIN tbl_Users_AccessLevelID p ON t.AccessLevelID = p.AccessLevelID ORDER BY UserName"; <br />
SqlDataAdapter myDataAdapter = new SqlDataAdapter(strSQLDDL, myConnection); <br />
myDataAdapter.Fill(ddlDataSet2, "ddlAccessLevels"); <br />
return ddlDataSet2; <br />
} <br />
<br />
<br />
private DataSet GetReportTos() <br />
{ <br />
const string strSQLDDL = @"SELECT ReportToID, UserName From tbl_Users Where ReportToID = UserID"; <br />
SqlDataAdapter myDataAdapter = new SqlDataAdapter(strSQLDDL, myConnection); <br />
myDataAdapter.Fill(ddlDataSet3, "ddlReportTos"); <br />
return ddlDataSet3; <br />
} <br />
<br />
<br />
private void DataGridUserManagementID_SelectedIndexChanged(object sender, System.EventArgs e) <br />
{ <br />
} <br />
<br />
<br />
<br />
protected void SelectedIndexChangedEventHandler(object sender, System.EventArgs e) <br />
{ <br />
DropDownList ddl=(DropDownList)sender; <br />
DataGridItem dgi=(DataGridItem)ddl.Parent.Parent; <br />
} <br />
<br />
<br />
private void UpdateDB(string cmd) <br />
{ <br />
myConnection.Open( ; <br />
<br />
System.Data.SqlClient.SqlCommand command = new System.Data.SqlClient.SqlCommand( ; <br />
command.Connection = myConnection; <br />
command.CommandText = cmd; <br />
command.ExecuteNonQuery( ; <br />
} <br />
<br />
<br />
<br />
<br />
private void BindData() <br />
{ <br />
<br />
<br />
string connectionString = "server=(local);uid=sa;pwd=;database=MSPOS"; <br />
System.Data.SqlClient.SqlConnection connection = new System.Data.SqlClient.SqlConnection(connectionString); <br />
<br />
<br />
<br />
string commandString = "SELECT t.UserID, p.Store, pe.AccessLevel, t.UserName, t.FullName, t.ReportToID From tbl_Users t INNER JOIN tbl_Users_StoreID p ON t.StoreID = p.StoreID INNER JOIN tbl_Users_AccessLevelID pe ON t.AccessLevelID = pe.AccessLevelID ORDER BY UserName"; <br />
<br />
System.Data.SqlClient.SqlCommand command = new System.Data.SqlClient.SqlCommand(); <br />
command.CommandText = commandString; <br />
command.Connection = connection; <br />
connection.Open(); <br />
SqlDataReader reader = command.ExecuteReader(CommandBehavior.CloseConnection); <br />
DataGridUserManagementID.DataSource=reader; <br />
DataGridUserManagementID.DataBind(); <br />
<br />
} <br />
<br />
<br />
<br />
private void DataGridUserManagementID_ItemDataBound(object sender, <br />
System.Web.UI.WebControls.DataGridItemEventArgs e) <br />
{ <br />
<br />
if(e.Item.ItemType == ListItemType.EditItem) <br />
{ <br />
<br />
<br />
<br />
} <br />
<br />
} <br />
<br />
<br />
private void DataGridUserManagementID_Edit(object source, <br />
System.Web.UI.WebControls.DataGridCommandEventArgs e) <br />
{ <br />
DataGridUserManagementID.EditItemIndex = e.Item.ItemIndex; <br />
BindData(); <br />
DataGridUserManagementID.ShowFooter = false; <br />
} <br />
<br />
<br />
private void DataGridUserManagementID_Cancel(object source,System.Web.UI.WebControls.DataGridCommandEventArgs e) <br />
{ <br />
DataGridUserManagementID.EditItemIndex = -1; <br />
BindData(); <br />
DataGridUserManagementID.ShowFooter = true; <br />
<br />
} <br />
<br />
<br />
protected void GridDropDown_SelectedIndexChanged(object sender, EventArgs e) <br />
{ <br />
} <br />
<br />
<br />
private void DataGridUserManagementID_ItemDataBound(object source,System.Web.UI.WebControls.DataGridCommandEventArgs e) <br />
{ <br />
Response.Write("The ItemDataBound Command has been fired"); <br />
<br />
if(e.Item.ItemType == ListItemType.EditItem) <br />
{ <br />
<br />
<br />
} <br />
<br />
<br />
<br />
} <br />
<br />
<br />
private int ExecuteQuery(string sqlCmd) <br />
{ <br />
string connectionString = "server=(local); uid=sa;pwd=;database=MSPOS"; <br />
System.Data.SqlClient.SqlConnection connection =new System.Data.SqlClient.SqlConnection(connectionString); <br />
connection.Open( ; <br />
System.Data.SqlClient.SqlCommand command = new System.Data.SqlClient.SqlCommand( ; <br />
command.CommandText = sqlCmd; <br />
command.Connection = connection; <br />
return command.ExecuteNonQuery( ; <br />
} <br />
<br />
private void DataGridUserManagementID_Update(object source,System.Web.UI.WebControls.DataGridCommandEventArgs e) <br />
{ <br />
string strUserID; <br />
string strStoreID, strStore; <br />
string strAccessLevelID, strAccessLevel; <br />
string strReportToID, strReportTo; <br />
string strUserName, strFullName; <br />
strUserID = ((Label)e.Item.FindControl("lblUserID")).Text; <br />
<br />
strStoreID = ((DropDownList)(e.Item.FindControl("ddlStores"))).SelectedItem.Value; <br />
strStore = ((DropDownList)(e.Item.FindControl("ddlStores"))).SelectedItem.Text; <br />
strAccessLevelID = ((DropDownList)(e.Item.FindControl("ddlAccessLevels"))).SelectedItem.Value; <br />
strAccessLevel = ((DropDownList)(e.Item.FindControl("ddlAccessLevels"))).SelectedItem.Text; <br />
<br />
strReportToID = ((DropDownList)(e.Item.FindControl("ddlReportTos"))).SelectedItem.Value; <br />
strReportTo = ((DropDownList)(e.Item.FindControl("ddlReportTos"))).SelectedItem.Text; <br />
strUserName = ((TextBox)e.Item.FindControl("editUserName")).Text; <br />
strFullName = ((TextBox)e.Item.FindControl("editFullName")).Text; <br />
Response.Write (strUserName + strReportTo); <br />
if ((strUserName.Equals(strReportTo))) <br />
{ strReportToID = strUserID; <br />
Response.Write ("Strings are Equal"); <br />
} <br />
string cmd="Update tbl_Users Set UserName='"+ strUserName +"', StoreID='"+ strStoreID +"', FullName='"+ strFullName +"', AccessLevelID='"+ strAccessLevelID +"', ReportToID='"+ strReportToID +"' Where UserID = "+ strUserID +""; <br />
ExecuteQuery(cmd); <br />
<br />
DataGridUserManagementID.EditItemIndex = -1; <br />
BindData( ; <br />
<br />
} <br />
<br />
<br />
public void DataGridUserManagementID_Delete(object source, <br />
System.Web.UI.WebControls.DataGridCommandEventArgs e) <br />
{ <br />
<br />
string cmd = "Delete from tbl_Users where UserID = " + DataGridUserManagementID.DataKeys[e.Item.ItemIndex]; <br />
int rowsDeleted = ExecuteQuery(cmd); <br />
<br />
DataGridUserManagementID.EditItemIndex = -1; <br />
BindData( ; <br />
} <br />
<br />
<br />
protected void lstItems_SelectedIndexChanged(object sender, System.EventArgs e) <br />
{ <br />
System.Web.UI.WebControls.DropDownList lst = <br />
(System.Web.UI.WebControls.DropDownList)sender; <br />
DataGridItem dgi = lst.Parent.Parent as DataGridItem; <br />
<br />
if(dgi != null) <br />
{ <br />
Response.Write("<br>ItemIndex: " + dgi.ItemIndex ); <br />
Response.Write("<br>Cells Count: " + dgi.Cells.Count); <br />
} <br />
<br />
} <br />
<br />
<br />
protected int GetSelectedIndex(string StoreID) <br />
{ <br />
int iLoop; <br />
DataTable dt = ddlDataSet1.Tables["ddlStores"]; <br />
for (iLoop=0; iLoop < dt.Rows.Count - 1; iLoop++) <br />
{ <br />
if (StoreID.Equals(dt.Rows[iLoop]["StoreID"].ToString())) <br />
return iLoop; <br />
}; <br />
return 0; <br />
<br />
} <br />
<br />
<br />
private SqlDataReader GetValues(string tableName) <br />
{ <br />
string connectionString = "server=(local);uid=sa;pwd=;database=MSPOS"; <br />
<br />
System.Data.SqlClient.SqlConnection connection = <br />
new System.Data.SqlClient.SqlConnection(connectionString); <br />
connection.Open( ; <br />
<br />
string commandString = "Select * from " + tableName; <br />
<br />
System.Data.SqlClient.SqlCommand command = <br />
new System.Data.SqlClient.SqlCommand( ; <br />
command.CommandText = commandString; <br />
command.Connection = connection; <br />
<br />
return command.ExecuteReader(CommandBehavior.CloseConnection); <br />
} <br />
<br />
</script> <br />
</HEAD> <br />
<body background="images/bg.gif" leftMargin="0" topMargin="0" marginheigh="0" marginwidth="0" <br />
bgColor="#fef9e9"> <br />
<uc1:header id="Header1" runat="server"></uc1:header> <br />
<form id="form1" runat="server"> <br />
<TABLE height="521" cellSpacing="0" cellPadding="0" width="742" border="0" ms_2d_layout="TRUE"> <br />
<TR vAlign="top"> <br />
<TD width="40" height="29"> <br />
<!-- Include start of header --------------------------------------------></TD> <br />
<TD width="702" height="29"> <br />
</TD> <br />
</TR> <br />
<TR vAlign="top"> <br />
<TD height="409"></TD> <br />
<TD><asp:datagrid id="DataGridUserManagementID" runat="server" OnUpdateCommand="DataGridUserManagementID_Update" <br />
OnEditCommand="DataGridUserManagementID_Edit" OnSelectedIndexChanged="DataGridUserManagementID_SelectedIndexChanged" <br />
AllowPaging="True" OnPreRender="DataGridUserManagementID_SelectedIndexChanged" OnItemDataBound="DataGridUserManagementID_ItemDataBound" AllowCustomPaging="True" <br />
AutoGenerateColumns="False" GridLines="None" BorderStyle="Solid" BorderColor="Black" BorderWidth="1px" <br />
CellPadding="2" CellSpacing="2" font-names="arial" font-size="X-Small" HorizontalAlign="Center" <br />
Width="700px"> <br />
<FooterStyle ForeColor="#330099" BackColor="#FFFFCC"></FooterStyle> <br />
<SelectedItemStyle Font-Bold="True" ForeColor="#663399" BackColor="#FFCC66"></SelectedItemStyle> <br />
<AlternatingItemStyle BackColor="PaleGoldenrod"></AlternatingItemStyle> <br />
<ItemStyle BackColor="Beige"></ItemStyle> <br />
<HeaderStyle Font-Bold="True" ForeColor="White" BackColor="#954896"></HeaderStyle> <br />
<Columns> <br />
<br />
<asp:EditCommandColumn ButtonType="LinkButton" UpdateText="<img src=../images/Ok.gif border=0 align=absmiddle alt='Save changes'>" <br />
CancelText="<img src=../images/Cancel.gif border=0 align=absmiddle alt='Cancel editing'>" EditText="<img src=../images/Edit.gif border=0 align=absmiddle alt='Edit this item'>"> <br />
<ItemStyle HorizontalAlign="Center" BackColor="Yellow"></ItemStyle> <br />
</asp:EditCommandColumn> <br />
<asp:TemplateColumn HeaderText="ID"> <br />
<ItemTemplate> <br />
<asp:Label Text='<%# Convert.ToString(DataBinder.Eval(Container.DataItem, "UserID")) %>' BackColor="lightblue" Font-Bold="true" Runat="server" ID="lblUserID"> <br />
</asp:Label> <br />
</ItemTemplate> <br />
</asp:TemplateColumn> <br />
<asp:TemplateColumn HeaderText="Store"> <br />
<ItemTemplate> <br />
<%# Convert.ToString(DataBinder.Eval(Container.DataItem, "Store")) %> <br />
</ItemTemplate> <br />
<EditItemTemplate> <br />
<asp:dropdownList ID="ddlStores" AutoPostBack="True" runat="server" DataTextField="Store" DataValueField="StoreID"></asp:dropdownlist> <br />
</EditItemTemplate> <br />
</asp:TemplateColumn> <br />
<br />
<asp:TemplateColumn HeaderText="AccessLevel"> <br />
<ItemTemplate> <br />
<%# Convert.ToString(DataBinder.Eval(Container.DataItem, "AccessLevel")) %> <br />
</ItemTemplate> <br />
<EditItemTemplate> <br />
<aspropdownList id="ddlAccessLevels" runat="server" DataSource='<%# GetAccessLevels() %>' DataValueField="AccessLevelID" DataTextField="AccessLevel"> <br />
</aspropdownList> <br />
</EditItemTemplate> <br />
</asp:TemplateColumn> <br />
<br />
<asp:TemplateColumn HeaderText="User Name"> <br />
<ItemTemplate> <br />
<asp:Label Text='<%# Convert.ToString(DataBinder.Eval(Container.DataItem,"UserName")) %>' Runat="server" ID="lblUserName"> <br />
</asp:Label> <br />
</ItemTemplate> <br />
<EditItemTemplate> <br />
<asp:TextBox Runat="server" ID="editUserName" Text = '<%# Convert.ToString(DataBinder.Eval(Container.DataItem,"UserName")) %>' Width="150"> <br />
</asp:TextBox> <br />
</EditItemTemplate> <br />
</asp:TemplateColumn> <br />
<br />
<asp:TemplateColumn HeaderText="Full Name"> <br />
<ItemTemplate> <br />
<asp:Label Text='<%# Convert.ToString(DataBinder.Eval(Container.DataItem,"FullName")) %>' Runat="server" ID="Label2"> <br />
</asp:Label> <br />
</ItemTemplate> <br />
<EditItemTemplate> <br />
<asp:TextBox Runat="server" ID="editFullName" Text = '<%# Convert.ToString(DataBinder.Eval(Container.DataItem,"FullName")) %>' Width="150"> <br />
</asp:TextBox> <br />
</EditItemTemplate> <br />
</asp:TemplateColumn> <br />
<asp:TemplateColumn HeaderText="Reports To"> <br />
<ItemTemplate> <br />
<%# Convert.ToString(DataBinder.Eval(Container.DataItem, "UserName")) %> <br />
</ItemTemplate> <br />
<EditItemTemplate> <br />
<aspropdownList runat="server" id="ddlReportTos" DataTextField="UserName" DataValueField="ReportToID" DataSource='<%# GetValues("tbl_Users") %>'> <br />
</aspropdownList> <br />
</EditItemTemplate> <br />
</asp:TemplateColumn> <br />
</Columns> <br />
</asp:datagrid> <br />
</TD> <br />
</TR> <br />
</TABLE> <br />
</form> <br />
</body> <br />
<br />
<br />
<br />
Please help me if you can and send the solution to mcupryk@sun.net.bb Thank you Sincerely.
Please help me if you can and send the solution to mcupryk@sun.net.bb Thank you Sincerely.
|
|
|
|
|
Hi,
How to change the color of status bar?
kalpu
|
|
|
|
|
My application is using a treeview to interact with the user. Opposite to the treeview i'm using a panel which contains content in the form of UserControls(Which often contain several UserControls). Each time the user chooses something in the treeview the content on the panel is changed. This is done by clearing the contents of the panel and disposing the controls which resides on it.
The panel is cleared using, where MainPanelCRF is the Panel:
private void clearPanel()
{
if(this.MainPanelCRF.Controls.Count > 0)
{
foreach(Control control in this.MainPanelCRF.Controls[0].Controls)
{
if(control != null)
{
control.Dispose();
}
}
this.MainPanelCRF.Controls[0].Dispose();
this.MainPanelCRF.Controls.Clear();
}
}
Even though I dispose the UserControls i'm seeing an increase in memory usage each time I change the UserControl on the panel. The memory increase does not seem to stop either. It easily succeeds 100 000K. Shouldn't the Garbage Collector collect the UserConrols that has been disposed? Is it possible that the UserControls is not disposed properly?
This has been giving me a headache for a couple of days now , has anyone got a suggestion as to how I can reduce the memory usage of my application?
Thanks,
Magnus Green
System Developer
Clinsoft AS
Norway
|
|
|
|
|
Questions like these should encourage you to dig into the assemblies using ildasm.exe from the SDK (if you can read IL) or use .NET Reflector or some other disassembler. Much of what you're doing is completely unecessary, and assuming that the GC will collect disposed objects is incorrect.
All controls extend Control which extends Component . The Component class uses the dispose pattern like so:
public class Component: IDisposable
{
~Component()
{
Dispose(false);
}
public void Dispose()
{
this.Dispose(true);
GC.SuppressFinalize(this);
}
protected virtual void Dispose(bool disposing)
{
}
} You can override Dispose(bool) in derivative classes to clean-up resources. This means that the object doesn't have to be finalized when you call IDisposable.Dispose explicitly on the control. If you're not cleaning-up all your resources, then finalization is being suppressed because your calling IDisposable.Dispose explicitly!
The Windows Forms controls are designed so that you don't have to call Dispose , nor should you. You should, however, override Dispose(bool) in derivative classes to free unmanaged resources (like window handles (HWND s), file handles, etc.) and call base.Dispose(bool) so that the parent classes can clean-up their resources:
protected override void Dispose(bool disposing)
{
base.Dispose(disposing);
} You'll notice the Windows Forms control templates do this already to dispose the child component collection when you add a new Form or UserControl .
So, don't dispose your controls unless you know all resources - managed and unmanaged - will be released. Even if you were to call GC.Collect for what you're currently doing, you would most likely see a memory leak depending on what your controls encapsulate.
This posting is provided "AS IS" with no warranties, and confers no rights.
Software Design Engineer
Developer Division Sustained Engineering
Microsoft
[My Articles]
|
|
|
|
|
Thanks for a great answer,
The UserControl s used in the application host a number of other controls, grids, UserConrols etc.
In addition to these the UserControl s also has some DataSet s which are bound to the UI controls. I've written code for disposing the resources used by the user control by overrinding the Dispose method of the UserControl . Is it necessary to explicity dispose of all Control s being used by the host control? All these conrols implement the IDisposable interface. Either way I still have a memory leak although I've tried to clean up my act.
When the main application window is minimized I notice that the resources used by the application is freed and that the memory usage drops down to a reasonable amount. Has anyone got a short explanation for this? Is there a way to do this without having to minimize the window?
Magnus Green
|
|
|
|
|
Almost any time you override a method you must call it's base implementation. This is especially true in the case of overriding Dispose(bool) , inheritted from Component . If you don't, the class members you don't free that either Component , Control , or any other derivatives know about won't be freed.
Again, though, you do not need to explicitly dispose Component s or its derivatives. They are designed so that you don't have to and it is recommend that you don't.
And of course all controls implement IDisposable - they inherit it from Component .
Why does memory drop when you minimize the application? If you read some of the links I gave you, you'd see that the GC runs when the application is idle or when memory is required and objects are available for GC'ing. When you minimize an application, it is considered idle because it does not receive user input (it may still be doing work, but only in the background).
As I hinted at before, you can call GC.Collect but this is highly not recommended because it can cause serious performance problems for your application. The fundamental problem here is your current design: either too many controls or you're not freeing everything you think you're freeing (and because you override Dispose(bool) you're not responsible for freeing everything, especially if you're not calling base.Dispose(bool) in your override).
This posting is provided "AS IS" with no warranties, and confers no rights.
Software Design Engineer
Developer Division Sustained Engineering
Microsoft
[My Articles]
|
|
|
|
|
Hi all,
This has probably been posted before but...
How do i remove the cross from the top right of a form.
I don't want the user to be able to close the form this way.
Cheers
Kev
|
|
|
|
|
Set MinimizeBox, MaximizeBox, and ControlBox to false.
--
Joel Lucsy
|
|
|
|
|
I can't, i need the user to be able to minimise the application as when they do this the application goes to the system tray instead of the task bar.
Kev
|
|
|
|
|
Then you're going to have to take a different approach. Windows itself requires a close box if either minimize or maximize is present.
Another method is to use the handler on the form for Closing. This will give you a change to say "no" and abort the close.
You'll get something like:
private void MainForm_Closing(object sender, System.ComponentModel.CancelEventArgs e)
where you can say:
e.Cancel = true;
--
Joel Lucsy
|
|
|
|
|
I am already doing that.
I was trying to restrict the cross being clicked, i suppose i could have a Hide button that set notifyIcon.Visible to true and hides the form.
Will give it a go anyways.
Cheers
Kev
|
|
|
|
|
|
That doesn't link to anything related to this topic
Kev
|
|
|
|
|
|
That would work but i would still need to stop alt + F4
Kev
|
|
|
|
|
Therefor write an event handler for the close event of your form and simply cancel the event.
To assure you could still close your form, you could declare a bool which will be set before you programmatically close your form and then will be checked inside the event handler.
www.troschuetz.de
|
|
|
|
|