Windows Develop Bookmark and Share   
 index > Windows Forms General > C# 2003 - Windows Forms Events
 

C# 2003 - Windows Forms Events

I am currently developing a windows application using C# .NET 2003.

I have a form that contains a DataGrid of the Requests that have been entered into the application. When this datagrid has data there is a button that the user can click that will bring up a form (in front of the DataGrid form)to allow the user to assign the request to another user. When they have closed out of the form that allows them to assign the task to another user I want to refresh the DataGrid. I have tried the Enter event of the Form, but this does not get fired when I close the other form. When the assign form is closed it looks as though the Assign button on the DataGrid form has focus. I tried using the Enter event of the button, but this didn't work either. What event would fire on the DataGrid Form that I can use to refresh the grid?

Thanks in advance for your help.

QuickTime  Wednesday, October 24, 2007 8:00 PM
in the button event handler (the one that brings up the child for) u call the
youForm f = new yourForm();
or something along that line then the form is show with f.Show() or f.ShowDialog(); what you can do is right after that code put datagridview1.Refresh(); and itshould refresh once the child for is closed. if this doesnt work with f.show() it should work with f.showdialog();
hope that helps.
Cameron Kloot  Wednesday, October 24, 2007 8:19 PM

Never mind. I found an answer that works. Thank you for your help Cameron it put me in the right direction anyway.

On the btnAssign_Click event on the calling formI have the following code.

frm_AssignTask fmAssignTask = new frm_AssignTask();

bLoadingAssignTask = true;

App.CurrentRequestID = RequestID;

fmAssignTask.Closed += new EventHandler(frm_AssignTask_Closed);

fmAssignTask.Disposed += new EventHandler(frm_AssignTask_Disposed);

fmAssignTask.ShowDialog();

The frm_AssignTask_Closed and frm_AssignTask_Disposed both reside in the calling form with the following commands:

private void frm_AssignTask_Closed(object sender, System.EventArgs e)

{

RetrieveDataset();

FormatGrid();

this.dtgTransactionQueue.Refresh();

this.BringToFront();

}

private void frm_AssignTask_Disposed(object sender, System.EventArgs e)

{

RetrieveDataset();

FormatGrid();

this.dtgTransactionQueue.Refresh();

this.BringToFront();

}

The RetrieveDataset method simply runs the query against the database again to get a refreshed recordset. The FormatGrid method simply sets up the DataGrid Columns with the MappingNames and HeaderText. Then we simply just to a refresh.

QuickTime  Thursday, October 25, 2007 8:43 PM
in the button event handler (the one that brings up the child for) u call the
youForm f = new yourForm();
or something along that line then the form is show with f.Show() or f.ShowDialog(); what you can do is right after that code put datagridview1.Refresh(); and itshould refresh once the child for is closed. if this doesnt work with f.show() it should work with f.showdialog();
hope that helps.
Cameron Kloot  Wednesday, October 24, 2007 8:19 PM

Cameron,

I put this code in place, so it reads like this:

frm_AssignTask fmAssignTask = new frm_AssignTask(); //Assignement Form

bLoadingAssignTask = true;

App.CurrentRequestID = RequestID;

fmAssignTask.ShowDialog(); //Assignement Form

this.dtgTransactionQueue.Refresh(); //Data Grid on the Data Grid Form

However, the datagrid refresh happens right after the Assign Task form loads and not after it has been closed.

Let me know if you have any other suggesstions.

QuickTime  Thursday, October 25, 2007 7:39 PM

Never mind. I found an answer that works. Thank you for your help Cameron it put me in the right direction anyway.

On the btnAssign_Click event on the calling formI have the following code.

frm_AssignTask fmAssignTask = new frm_AssignTask();

bLoadingAssignTask = true;

App.CurrentRequestID = RequestID;

fmAssignTask.Closed += new EventHandler(frm_AssignTask_Closed);

fmAssignTask.Disposed += new EventHandler(frm_AssignTask_Disposed);

fmAssignTask.ShowDialog();

The frm_AssignTask_Closed and frm_AssignTask_Disposed both reside in the calling form with the following commands:

private void frm_AssignTask_Closed(object sender, System.EventArgs e)

{

RetrieveDataset();

FormatGrid();

this.dtgTransactionQueue.Refresh();

this.BringToFront();

}

private void frm_AssignTask_Disposed(object sender, System.EventArgs e)

{

RetrieveDataset();

FormatGrid();

this.dtgTransactionQueue.Refresh();

this.BringToFront();

}

The RetrieveDataset method simply runs the query against the database again to get a refreshed recordset. The FormatGrid method simply sets up the DataGrid Columns with the MappingNames and HeaderText. Then we simply just to a refresh.

QuickTime  Thursday, October 25, 2007 8:43 PM

You can use google to search for other answers

Custom Search

More Threads

• How to always scroll to the last line in a textBox
• Audio/Video conferencing using .NET
• Windows forms or ASP.net
• Form Navigation
• DateTimePicker problem
• Sorting DataGridView unbound Column
• One process triggering an event on another process
• My Wish List...
• Visual Studio 2005 , Windows Forms DataGridView
• Table existence in a database