|
How about providing some code.
|
|
|
|
|
private void MainParent_Load(object sender, System.EventArgs e)
{
LoadNewConfig();
}
private void LoadNewConfig()
{
ControllerForm controllerForm = new ControllerForm();
controllerForm.MdiParent = this;
controllerForm.Show();
}
There is nothing to this code. The three lines in LoadNewConfig are the ones I remove and it works fine.
I Turned on the Exception Break into debugger option. (CTRL-ALT-E) and now I cac't get it to happen again.
grrrrrr
|
|
|
|
|
Does ur ControllerForm have any code yet?
If so, can u please post all ControllerForm code that gets called when instantiating?
If ur overriding any methods that might be getting called then please post them too.
|
|
|
|
|
no overrides... here is the code:
I included all the code from the Windows IDE generated.
public class ControllerForm : System.Windows.Forms.Form
{
private DevComponents.DotNetBar.DotNetBarManager dotNetBarManager1;
private DevComponents.DotNetBar.DockSite barLeftDockSite;
private DevComponents.DotNetBar.DockSite barRightDockSite;
private DevComponents.DotNetBar.DockSite barTopDockSite;
private DevComponents.DotNetBar.DockSite barBottomDockSite;
private System.ComponentModel.IContainer components;
string controllerName = "";
private System.Windows.Forms.OpenFileDialog openFile1;
string fileName = "";
public ControllerForm()
{
//
// Required for Windows Form Designer support
//
InitializeComponent();
//
// TODO: Add any constructor code after InitializeComponent call
//
}
public string ControllerName
{
get
{
return controllerName;
}
set
{
controllerName = value;
}
}
public string FileName
{
get
{
return fileName;
}
set
{
fileName = value;
}
}
///
/// Clean up any resources being used.
///
protected override void Dispose( bool disposing )
{
if( disposing )
{
if(components != null)
{
components.Dispose();
}
}
base.Dispose( disposing );
}
#region Windows Form Designer generated code
///
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
///
private void InitializeComponent()
{
this.components = new System.ComponentModel.Container();
this.dotNetBarManager1 = new DevComponents.DotNetBar.DotNetBarManager(this.components);
this.barBottomDockSite = new DevComponents.DotNetBar.DockSite();
this.barLeftDockSite = new DevComponents.DotNetBar.DockSite();
this.barRightDockSite = new DevComponents.DotNetBar.DockSite();
this.barTopDockSite = new DevComponents.DotNetBar.DockSite();
this.openFile1 = new System.Windows.Forms.OpenFileDialog();
this.SuspendLayout();
//
// dotNetBarManager1
//
this.dotNetBarManager1.AutoDispatchShortcuts.Add(DevComponents.DotNetBar.eShortcut.F1);
this.dotNetBarManager1.AutoDispatchShortcuts.Add(DevComponents.DotNetBar.eShortcut.CtrlC);
this.dotNetBarManager1.AutoDispatchShortcuts.Add(DevComponents.DotNetBar.eShortcut.CtrlA);
this.dotNetBarManager1.AutoDispatchShortcuts.Add(DevComponents.DotNetBar.eShortcut.CtrlV);
this.dotNetBarManager1.AutoDispatchShortcuts.Add(DevComponents.DotNetBar.eShortcut.CtrlX);
this.dotNetBarManager1.AutoDispatchShortcuts.Add(DevComponents.DotNetBar.eShortcut.CtrlZ);
this.dotNetBarManager1.AutoDispatchShortcuts.Add(DevComponents.DotNetBar.eShortcut.Del);
this.dotNetBarManager1.AutoDispatchShortcuts.Add(DevComponents.DotNetBar.eShortcut.Ins);
this.dotNetBarManager1.BottomDockSite = this.barBottomDockSite;
this.dotNetBarManager1.DefinitionName = "ControllerForm.dotNetBarManager1.xml";
this.dotNetBarManager1.LeftDockSite = this.barLeftDockSite;
this.dotNetBarManager1.ParentForm = this;
this.dotNetBarManager1.RightDockSite = this.barRightDockSite;
this.dotNetBarManager1.Style = DevComponents.DotNetBar.eDotNetBarStyle.Office2003;
this.dotNetBarManager1.TopDockSite = this.barTopDockSite;
this.dotNetBarManager1.ContainerLoadControl += new System.EventHandler(this.ContainerLoadControl);
//
// barBottomDockSite
//
this.barBottomDockSite.AccessibleRole = System.Windows.Forms.AccessibleRole.Window;
this.barBottomDockSite.BackgroundImageAlpha = ((System.Byte)(255));
this.barBottomDockSite.Dock = System.Windows.Forms.DockStyle.Bottom;
this.barBottomDockSite.Location = new System.Drawing.Point(0, 466);
this.barBottomDockSite.Name = "barBottomDockSite";
this.barBottomDockSite.Size = new System.Drawing.Size(692, 0);
this.barBottomDockSite.TabIndex = 3;
this.barBottomDockSite.TabStop = false;
//
// barLeftDockSite
//
this.barLeftDockSite.AccessibleRole = System.Windows.Forms.AccessibleRole.Window;
this.barLeftDockSite.BackgroundImageAlpha = ((System.Byte)(255));
this.barLeftDockSite.Dock = System.Windows.Forms.DockStyle.Left;
this.barLeftDockSite.Location = new System.Drawing.Point(0, 0);
this.barLeftDockSite.Name = "barLeftDockSite";
this.barLeftDockSite.Size = new System.Drawing.Size(0, 466);
this.barLeftDockSite.TabIndex = 0;
this.barLeftDockSite.TabStop = false;
//
// barRightDockSite
//
this.barRightDockSite.AccessibleRole = System.Windows.Forms.AccessibleRole.Window;
this.barRightDockSite.BackgroundImageAlpha = ((System.Byte)(255));
this.barRightDockSite.Dock = System.Windows.Forms.DockStyle.Right;
this.barRightDockSite.Location = new System.Drawing.Point(590, 0);
this.barRightDockSite.Name = "barRightDockSite";
this.barRightDockSite.Size = new System.Drawing.Size(102, 466);
this.barRightDockSite.TabIndex = 1;
this.barRightDockSite.TabStop = false;
//
// barTopDockSite
//
this.barTopDockSite.AccessibleRole = System.Windows.Forms.AccessibleRole.Window;
this.barTopDockSite.BackgroundImageAlpha = ((System.Byte)(255));
this.barTopDockSite.Dock = System.Windows.Forms.DockStyle.Top;
this.barTopDockSite.Location = new System.Drawing.Point(0, 0);
this.barTopDockSite.Name = "barTopDockSite";
this.barTopDockSite.Size = new System.Drawing.Size(692, 0);
this.barTopDockSite.TabIndex = 2;
this.barTopDockSite.TabStop = false;
//
// ControllerForm
//
this.AutoScaleBaseSize = new System.Drawing.Size(5, 13);
this.ClientSize = new System.Drawing.Size(692, 466);
this.Controls.Add(this.barLeftDockSite);
this.Controls.Add(this.barRightDockSite);
this.Controls.Add(this.barTopDockSite);
this.Controls.Add(this.barBottomDockSite);
this.Name = "ControllerForm";
this.Text = "Controller";
this.WindowState = System.Windows.Forms.FormWindowState.Maximized;
this.Load += new System.EventHandler(this.ControllerForm_Load);
this.ResumeLayout(false);
}
#endregion
private void ContainerLoadControl(object sender, System.EventArgs e)
{
// Always cast to the BaseItem first, since sender in this case could be ControlContainerItem or DockContainerItem
BaseItem item = sender as BaseItem;
if(item.Name=="Dock1")
{
DockContainerItem dockItem=item as DockContainerItem;
dockItem.Control=new ConfigStepsList();
// Assign optional "Customize" menu to the bar that contains this item
if(item.CanCustomize==true)
{
item.CanCustomize=false;
}
}
}
private void ControllerForm_Load(object sender, System.EventArgs e)
{
openFile();
}
private void openFile()
{
if(openFile1.ShowDialog()==DialogResult.OK)
{
string name = openFile1.FileName;
}
}
}
|
|
|
|
|
I've run ur code and it works perfectly under these conditions:
1) No devcomponents
Could be some fault in the assembly? Have u tried running the code commenting out all DevComponent references?
One thing i've noticed in your ContainerLoadControl event handler:
Ur safe casting "sender" into a "BaseItem" through "BaseItem item = sender as BaseItem;"
but then, on the next line, ur not taking into account that the cast might fail and "item" be a null reference. In that case "item.Name" will fail. Can ur error be in ur event handler? This error might be triggering while the form is performing native calls during loadup and thus the debugger cannot catch it properly. Try commenting it out and see what happens or try putting ur code after the safecast in this way and see what happens: if(item!=null) {//your code}
|
|
|
|
|
I am a newbie as well, but could you use thread.join to have your parent form wait until the child is complete?
Can't remember if each for is it's own thread, or if you would need to start the child form on it's own thread. I think the former is correct.
www.lovethosetrains.com
|
|
|
|
|
Dwayner79 wrote:
My thoughts on this is that the code is failing because the parent is leaving the function that called the child.
Of course it is! That's what it's supposed to do.
The problem is not because the function is returning, but because your code, somewhere else down the line, of either the MDI Parent or the Child form, is referencing an object that doesn't have an instance yet.
If you're running this under the debugger, it'll show you which line is throwing the exception. What does the code look like? I'd be willing to bet that it has something to do with the Load event of the Child form.
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
I posted code above. I tried running under the debugger and step through the code, it does not fail.
I changed to "Break into the debugger" under the Exceptions window, but it still does not tell me what line of code the problem is on.
Thanks for the help.
|
|
|
|
|
Hello,
I have my mdi form. One of the child forms displays a datagrid of employee salaries.
On the mdi form l have a button called update. I want to pass the Employee ID number from the grid and display it in another form.
This is what l have done so far, but does not work.
In the salaries form (datagrid form) i have this code.
<br />
private string employeeNumber;<br />
employeeNumber = grdSalaries[grdSalaries.CurrentRowIndex,0];<br />
<br />
<br />
public string getEmployeeNumber<br />
{<br />
get<br />
{<br />
return employeeNumber;<br />
}<br />
set<br />
{<br />
value = employeeNumber;<br />
}<br />
}
In the update form l have this code in the form load.
employeeNumber = parent.getEmployeeNumber;
I have declared these above the constructor
private string employeeNumber;<br />
frmSalaries parent;
My constructor is listed below
public frmUpdateEmployee(frmSalaries form)<br />
{<br />
InitializeComponent();<br />
<br />
parent = form;<br />
}
The error message is below
An unhandled exception of type 'System.NullReferenceException' occurred in payrole.exe
Additional information: Object reference not set to an instance of an object.
The way the program works is the main control buttons are displayed in the mdi, when you click on show salaries it displays the form with the grid. The user will click once on the grid and then click on the update button on the mdi form. This will then display another form which is passed the ID number so l know who i have to update.
Many thanks in advance,
Steve
|
|
|
|
|
I think the problem is , not the passing, you can't grab the data , and by default you didnt set employeeNumber to a value , private string employeeNumber;
NullReferenceException occurs , because this line
employeeNumber = grdSalaries[grdSalaries.CurrentRowIndex,0];
could not set any value to the employeeNumber, and by default , you didnt set any value neither.
First, to be sure , set the value of employeeNumber = 0 ;
if there is still an exception , I guess there might be another problem.
If the value sent to the child form is 0 ,
you should consider the line
employeeNumber = grdSalaries[grdSalaries.CurrentRowIndex,0];
Thats all I know..
I hope , I could help.
|
|
|
|
|
Hi everyone,
I am working in the serialization of some objects that reference each other (as a graph) and I am using BinaryFormatter. In addition, I have implemented ISerializable interface in all classes being serializaed (it was really necessary!) .
The problem that I found which is stopping my work and putting in trouble with the boss is as follow:
The GetObjectData method of some objects is called more than once at the serialization, I suppose it is being serialized more than once. Am I right?
This unexpected behavior (unexpected for me!) is causing some other problems like large files, long time serialization and others...
Can someone help me with that?
All help will be welcome!
Thanks!
Fernando Miranda
Software Developer
Rio de Janeiro - Brazil
|
|
|
|
|
In C#, I Override the TabControl and TabPage(Change the font Only). In Application form, I use them, When I write
tabcontrol.Focus(); the Focus can't set the tabControl. otherwise, I using Windows.Form.Tabcontrol and TabPage, this problem is not.
Why? How to do it?
|
|
|
|
|
Can't say what the immediate problem is, but I had a similar problem, which I solved using the " TabControl using Custom TabPages." example on this homepage: http://dotnetrix.co.uk/tabcontrols.html
hope it helps
-spif2001
|
|
|
|
|
In C#, When using GetString method that returns the substring at the specified location within a String object.If the string is a unicode string, I want to get correct string only.
For example:
byte[] bytes;
bytes = System.Text.Encoding.Default.GetBytes("これはテストです123456");
string strReturn = System.Text.Encoding.Default.GetString(bytes, 3, 4);
I want to get 'は' only.
How to do it?
Thanks.
|
|
|
|
|
Why don't you just call Substring() for the original string?
mav
|
|
|
|
|
I want to get bytes length's string only. For example:
This string is "これはテストです".
I want to have a method like Mid in MFC, but char, 'れ' is two bytes.
getsubstring("これはテストです", 2, 2) return "れ";
getsubstring("これはテストです", 3, 2) return "";
getsubstring("これはテストです", 3, 4) return "れ";
...
|
|
|
|
|
With .NET, one character is not equal one byte!
Substring() gets the character position to start and the number of characters to return.
So calling
"これはテストです".Substring(1,1) returns "れ"
"これはテストです".Substring(2,1) returns "は"
"これはテストです".Substring(2,2) returns "はテ"
mav
(who's using strange characters he doesn't recognize or understand and hopes he didn't write anything obscene... )
|
|
|
|
|
|
Then your OS/browser is not unicode-enabled.
mav
|
|
|
|
|
Is there anyway for me to view the incoming SOAP message that my web service is receiving??
Do I need to write any code to perform such operation or is that any free viewer that I can use to do that??
Thanks.
|
|
|
|
|
Look for SoapExtension[^] class.
Mazy
"One who dives deep gets the pearls,the burning desire for realization brings the goal nearer." - Babuji
|
|
|
|
|
Hi all,
I've written a component inherited from System.ComponentModel.Component, and put it in web form toolbox. When I drag it to web form,the form designer will auto-generate the code to initialize the component in InitializeComponent() method. The code looks like this:
private void InitializeComponent()
{
this.components = new System.ComponentModel.Container();
this.component11 = new ComponentSample.Component1(this.components);
//
// component11
//
this.component11.Name = "Hello";
this.Load += new System.EventHandler(this.Page_Load);
}
However, I wanna replace the code that invoke constructor with the other one and transfer the page object as parameter to it.it will like this:
this.component11 = new ComponentSample.Component1(this.components, this); // constructor has definded in Component1
Could anyone tell me if it's possible to let designer auto-generate the initialize code to invoke the constructor that I definded and transfer the page object to it?If yes, how is it done?
Thank you so much.
|
|
|
|
|
Hi all!
I'm searching for a viable way to insert data into a stream. In my case, the stream is a stream of wave audio data that's being written to a file (simple audio recorder).
The problem arises when I want to add the possibility to choose between insert and overwrite mode for recording.
Overwrite is simple - just Seek() to the correct position and continue to write the audio data to the file stream.
But when the user wants to insert, I'd have to split the file, append to the first part and, at the end of the recording, append the second part to the new file.
I guess this might produce a noticeable delay, won't it?
Is there a different/better way to do this?
mav
|
|
|
|
|
Depending on the size of the file your manipulating, yes it would. Is there another way to do it? About the best you can do is to skip splitting the file and just record the new sound you want to insert into a 2nd file. When that's done, you'll have to open the original file, copy as much information as you need into a 3rd file, copy the data you need from the the 2nd file into the 3rd file, then copy the remaining data from the original file, and finally, delete the 1st file, 2nd file, and rename the 3rd file to the name of the first file.
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
Yeah, that would be the straightforward process...
Or I could create a set of several "buffers" organized in a kind of linked list, so that the chunks that have to be split cannot become very large...
But then synchronizing these buffers with the file can become quite tricky.
Any other, more elegant ways?
mav
|
|
|
|
|