473,473 Members | 1,713 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

Q: SendKeys and MdiChildren

Hi,

I have multiple Mdi child forms within a parent form. All Mdi child forms
will have one DataGrid on it, the DataGrid is bind to a DataView and the
DataView is again bind to a DataTable. In addition, there is a save button
on the parent form.

My problem is if a user finish input data into the last cell of the DataGrid
of an active child form but never press the control+enter key or navigate to
other cell. The current row will still in edit mode (a pen icon infornt of
the first column of current row).

Then if the user press on the save button on the parent form, the last input
data will not be saved. I have tried SendKeys, but it doesn't work!!

When the save button being clicked, it will loop through all Mdi child forms
and call the following function in all Mdi child forms to get the updated
DataTable:

public DataTable UpdatedTable
{
get
{
SendKeys.Send("^{ENTER}");
return this.dataTable.GetChanges();
}
}

I understand that the SendKey doesn't have to be in all Mdi child forms, I
am just testing it out. Can anyone help me on this issue?

Thank you.

--
Soul

Nov 15 '05 #1
3 2527
Soul,

I think that what you want to do is get the BindingManagerBase for the
form (which is keyed on the DataView that the grid is bound to). When you
have that, you can call the EndCurrentEdit method and it should commit
whatever you were editing. You can do this before you save the data back to
the grid.

Hope this helps.
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com

"Soul" <no@spam.com> wrote in message
news:eY***************@tk2msftngp13.phx.gbl...
Hi,

I have multiple Mdi child forms within a parent form. All Mdi child forms
will have one DataGrid on it, the DataGrid is bind to a DataView and the
DataView is again bind to a DataTable. In addition, there is a save button
on the parent form.

My problem is if a user finish input data into the last cell of the DataGrid of an active child form but never press the control+enter key or navigate to other cell. The current row will still in edit mode (a pen icon infornt of
the first column of current row).

Then if the user press on the save button on the parent form, the last input data will not be saved. I have tried SendKeys, but it doesn't work!!

When the save button being clicked, it will loop through all Mdi child forms and call the following function in all Mdi child forms to get the updated
DataTable:

public DataTable UpdatedTable
{
get
{
SendKeys.Send("^{ENTER}");
return this.dataTable.GetChanges();
}
}

I understand that the SendKey doesn't have to be in all Mdi child forms, I
am just testing it out. Can anyone help me on this issue?

Thank you.

--
Soul

Nov 15 '05 #2
Hi,

I tried, but it doesn't work. I think it is because I don't really
understand about the BindingManagerBase. I tried to follow the example from
MSDN and modified my code as follow:

// private variebles declared here
....
....

public myForm(DataTable aTable)
{
InitializeComponent();

this.myDT = aTable;
this.tableName = this.myDataTable.TableName.ToString();
this.myDV = new DataView(this.myDT);
this.myDG.DataSource = this.myDV;

/* I think I did something wrong here. */
this.bingingManagerBase = (CurrencyManager) BindingContext[this.myDV];

this.myDV.AllowNew = false;
this.myDV.AllowDelete = true;
this.dataGridTableStyle.MappingName = tableName;
this.myDT.ColumnChanging += new
DataColumnChangeEventHandler(this.dataTable_ValueC hanging);
}

public DataTable UpdatedTable
{
get
{
this.bingingManagerBase.EndCurrentEdit();

MessageBox.Show(this.dataTable.Rows[this.dataGrid.CurrentCell.RowNumber]["ta
skMarks"].ToString());
return this.dataTable.GetChanges();
}
}

Once the user click on the save button on the parent form, the UpdatedTable
in the child form will be called. But I still see the current editing row of
the DataGrid in the active child form still in editing mode.

Please show me where did I miss out?

Thank you.

--
Soul
"Nicholas Paldino [.NET/C# MVP]" <mv*@spam.guard.caspershouse.com> wrote in
message news:Of**************@TK2MSFTNGP10.phx.gbl...
| Soul,
|
| I think that what you want to do is get the BindingManagerBase for the
| form (which is keyed on the DataView that the grid is bound to). When you
| have that, you can call the EndCurrentEdit method and it should commit
| whatever you were editing. You can do this before you save the data back
to
| the grid.
|
| Hope this helps.
|
|
| --
| - Nicholas Paldino [.NET/C# MVP]
| - mv*@spam.guard.caspershouse.com
|
| "Soul" <no@spam.com> wrote in message
| news:eY***************@tk2msftngp13.phx.gbl...
|
| > [Snipped]

Nov 15 '05 #3
Ah Ha... I found the solution!

....
this.dataView = new DataView(this.dataTable);
this.dataGrid.DataSource = this.dataView;
this.currencyManager = (CurrencyManager)
this.BindingContext[this.dataTable];

public void CompleteEdit()
{
this.dataGrid.EndEdit(this.dataGridTextBoxColumnTa skMarks,
this.dataGrid.CurrentCell.RowNumber, false);
this.currencyManager.Position = this.dataGrid.CurrentCell.RowNumber;
this.currencyManager.EndCurrentEdit();
}

But I don't understand why calling the CurrencyManager.EndCurrentEdit() is a
must after calling the DataGrid.EndEdit()!?!?

--
Soul
"Soul" <no@spam.com> wrote in message
news:e8**************@TK2MSFTNGP11.phx.gbl...
| Hi,
|
| I tried, but it doesn't work. I think it is because I don't really
| understand about the BindingManagerBase. I tried to follow the example
from
| MSDN and modified my code as follow:
|
| // private variebles declared here
| ...
| ...
|
| public myForm(DataTable aTable)
| {
| InitializeComponent();
|
| this.myDT = aTable;
| this.tableName = this.myDataTable.TableName.ToString();
| this.myDV = new DataView(this.myDT);
| this.myDG.DataSource = this.myDV;
|
| /* I think I did something wrong here. */
| this.bingingManagerBase = (CurrencyManager) BindingContext[this.myDV];
|
| this.myDV.AllowNew = false;
| this.myDV.AllowDelete = true;
| this.dataGridTableStyle.MappingName = tableName;
| this.myDT.ColumnChanging += new
| DataColumnChangeEventHandler(this.dataTable_ValueC hanging);
| }
|
| public DataTable UpdatedTable
| {
| get
| {
| this.bingingManagerBase.EndCurrentEdit();
|
|
MessageBox.Show(this.dataTable.Rows[this.dataGrid.CurrentCell.RowNumber]["ta
| skMarks"].ToString());
| return this.dataTable.GetChanges();
| }
| }
|
| Once the user click on the save button on the parent form, the
UpdatedTable
| in the child form will be called. But I still see the current editing row
of
| the DataGrid in the active child form still in editing mode.
|
| Please show me where did I miss out?
|
| Thank you.
|
| --
| Soul
|
|
| "Nicholas Paldino [.NET/C# MVP]" <mv*@spam.guard.caspershouse.com> wrote
in
| message news:Of**************@TK2MSFTNGP10.phx.gbl...
| | Soul,
| |
| | I think that what you want to do is get the BindingManagerBase for
the
| | form (which is keyed on the DataView that the grid is bound to). When
you
| | have that, you can call the EndCurrentEdit method and it should commit
| | whatever you were editing. You can do this before you save the data
back
| to
| | the grid.
| |
| | Hope this helps.
| |
| |
| | --
| | - Nicholas Paldino [.NET/C# MVP]
| | - mv*@spam.guard.caspershouse.com
| |
| | "Soul" <no@spam.com> wrote in message
| | news:eY***************@tk2msftngp13.phx.gbl...
| |
| | > [Snipped]
|

Nov 15 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: Mr. Bungle | last post by:
I would like to send email automatically via a command button. I have accomplished this just fine through the following code: (Outlook should already be open for reliable results) Private Sub...
2
by: RBohannon | last post by:
I need to create a report in MS Word populated with data from A2K. I have been asked to create the report in Word so that parts of it can be edited as necessary later. The data in the report are...
1
by: George | last post by:
Every time I used the Sendkeys command in my application the "Numlock" turned off and I couldn't use the keypad to hit numbers...... The old code was: Private Sub Command1_Click() SendKeys...
5
by: Wayne Gibson | last post by:
Hi, Was wondering if somebody could help.. I'm trying to use Sendkeys on a Windows forms. I have entered the following command to simulate a CTRL+ALT+1.. ...
1
by: Bryan | last post by:
I am writing a C# Windows App that updates out Excel reports' modules. The app is complete, but has a problem. The only way MS allows you to unprotect the VBA code in Excel is to do it by hand or...
1
by: GrantS | last post by:
I need to use a sendkeys key combination to automate the "accept files" that a remote user wants to send to me via Windows messenger. I am using automation to work with Windows Messenger client in...
4
by: DraguVaso | last post by:
Hi, I have a Form which has the property IsMdiContainer = True. So it contains a whole bunch of MdiChilds. Those MdiChilds are all instances of two forms I have: I have some that are an instance...
6
by: Michael Maes | last post by:
Hello, I'm invoking successive SendKeys.SendWait("{BACKSPACE}") SendKeys.SendWait("{DELETE}") in a loop. The issue is that it causes a Beep on every Pass. Setting the 'Handled = True' on...
0
by: dtshedd | last post by:
I have a database with hundreds of embedded photos (Microsoft Photo 3.0) Many are larger than 1 MB. I tried Stephen Lebans macro but it did not work probably for the aforementioned reasons Now...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
1
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
0
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.