|
Hi,
I’m writing a new WinForms app (C#, .Net Core, Visual Studio 2019 Preview). The App was intended to take the form of an MDI Parent container with multiple MDI Child forms; however, I need to allow some of the child forms to leave the MDI Parent container and display on a second or third monitor. I really like the way that Visual Studio does this, the way it allows you to dock a pane within the main container but also allows you to drag panes out of the main container to show on a secondary monitor. Is that possible with an MDI parent/child scenario (I suspect not)? If not, what would be the best way to achieve it?
Thanks in advance
|
|
|
|
|
|
Thanks, will do. 
|
|
|
|
|
Working with a DataGridView and a custom control: Is it at all possible for an array to be a parameter in a custom control? The high and low limits for every cell in the grid may be different. It would be nice to have this 3 dimensional array to be part of the parameters.
I have read articles that say that it is not possible to have any array to be a parameter in a control. They suggest forgetting DataGridView and doing something like an array of textbox. The grids in the app are always a fixed size and never use scroll bars.
So many years of programming I have forgotten more languages than I know.
|
|
|
|
|
michaelbarb wrote: have read articles that say that it is not possible In which case move the validation from the constructor to the events, trap the key up or leave event of each cell and validate the content in the event.
Never underestimate the power of human stupidity -
RAH
I'm old. I know stuff - JSOP
|
|
|
|
|
I have done this for a set of limits that apply to all cells. I even got it work on a per column basis by make a lot of separate parameters. I need every cell to have different limits. Trying to pass a large array of limits into a derived control of DataGridView is the problem.
So many years of programming I have forgotten more languages than I know.
|
|
|
|
|
michaelbarb wrote: it is not possible to have any array to be a parameter in a control. That is a very broad statement, and it would depend entirely in what the control is doing and what information it needs to process.
|
|
|
|
|
I realize it is a broad statement but it is mostly a quote. I am trying to pass a large array of limits into a derived control of DataGridView.
So many years of programming I have forgotten more languages than I know.
|
|
|
|
|
Sorry, but we cannot guess what your code is or is not doing, either right or wrong.
|
|
|
|
|
I had wanted to make the limit array a control property. I found another way. I made a separate array loaded the array into additional cells in the DataGridView and then made the extra rows invisible.
So many years of programming I have forgotten more languages than I know.
|
|
|
|
|
You could use the Tag property, it can hold any Object.
|
|
|
|
|
|
Could you please at least show me a screen shot or what is your usercontrol code ?
|
|
|
|
|
This has been long ago and I do not have access to the example or remember all the details. In the other question I linked to I had written this comment:
"Working backward I found that when you use a parameter "this.Text" or anything with "this" you cannot add it from the toolbox. The control works as expected with each instance of the tool working from its own parameters. You can copy and paste it with out problem with out problem. You just cannot get it from the Toolbox."
So many years of programming I have forgotten more languages than I know.
|
|
|
|
|
OK, glad you found a solution.
|
|
|
|
|
None of the key events are working. I have tried several approached and none work. I m using Windows 10, .NET 4.8.
So many years of programming I have forgotten more languages than I know.
|
|
|
|
|
Before you complain select is broken, do include a sample. Otherwise, not looking at it
Bastard Programmer from Hell
If you can't read my code, try converting it here[^]
"If you just follow the bacon Eddy, wherever it leads you, then you won't have to think about politics." -- Some Bell.
|
|
|
|
|
 There is not much more to say. Create a new windows form project. Put a DataGridView in the form. Go to the events for the DataGridView. Double click any or all of the key events. Go to the code behind. Put trivial line in each event (int i = 0; i = I+1;) and set a break point. You will never trip the key events.
I tried each event without the others present. As a last test I added event "CellValueChanged" to see if I was getting some event and it worked.
namespace DataGridView_Events
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
InitializeTable();
}
private void InitializeTable()
{
dataGridView1.ColumnCount = 3;
dataGridView1.Columns[0].Name = "Column0";
dataGridView1.Columns[1].Name = "Column1";
dataGridView1.Columns[2].Name = "Column2";
dataGridView1.Rows.Add(5);
dataGridView1.Rows[0].HeaderCell.Value = "Row1";
dataGridView1.Rows[1].HeaderCell.Value = "Row2";
dataGridView1.Rows[2].HeaderCell.Value = "Row3";
for (int i = 0; i < 3; i++)
{
dataGridView1.Rows[i].Cells[0].Value = 0 + i;
dataGridView1.Rows[i].Cells[1].Value = 10 + i;
dataGridView1.Rows[i].Cells[2].Value = 20 + i;
}
dataGridView1.Refresh();
}
private void dataGridView1_KeyPress(object sender, KeyPressEventArgs e)
{
int i = 0; i = i + 1;
}
private void dataGridView1_KeyDown(object sender, KeyEventArgs e)
{
int i = 0; i = i + 1;
}
private void dataGridView1_KeyUp(object sender, KeyEventArgs e)
{
int i = 0; i = i + 1;
}
private void dataGridView1_CellValueChanged(object sender, DataGridViewCellEventArgs e)
{
int i = 0; i = i + 1;
}
}
}
So many years of programming I have forgotten more languages than I know.
|
|
|
|
|
|
Thanks. I needed to add the following to pass the event up:
private void dataGridView1_EditingControlShowing(object sender, DataGridViewEditingControlShowingEventArgs e)
{
e.Control.KeyPress += new KeyPressEventHandler(dataGridView1_KeyPress);
}
So many years of programming I have forgotten more languages than I know.
|
|
|
|
|
You need to explain what not working" actually means. As it stands it is anyone's guess what you are doing wrong.
|
|
|
|
|
Now how do I do it when I put it in a custom control.
protected override void OnKeyPress(KeyPressEventArgs e)
{
base.OnKeyPress(e);
}
protected override void OnEditingControlShowing(DataGridViewEditingControlShowingEventArgs e)
{
e.Control.KeyPress += new KeyPressEventHandler(OnKeyPress);
base.OnEditingControlShowing(e);
}
I get an error on the OnKeyPress in setting the event handler:
No overload for 'OnKeyPress' matches delegate in 'KeyPressEventHandler'
So many years of programming I have forgotten more languages than I know.
|
|
|
|
|
Simple:
protected override void OnKeyPress(KeyPressEventArgs e)
{
base.OnKeyPress(e);
HandleKeyPress(this, e);
}
protected override void OnEditingControlShowing(DataGridViewEditingControlShowingEventArgs e)
{
base.OnEditingControlShowing(e);
e.Control.KeyPress += HandleKeyPress;
}
protected virtual void HandleKeyPress(object sender, KeyPressEventArgs e)
{
}
"These people looked deep within my soul and assigned me a number based on the order in which I joined."
- Homer
|
|
|
|
|
Beautiful, Thank you. The event OnKeyPress never gets used.
So many years of programming I have forgotten more languages than I know.
|
|
|
|
|