|
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
|
|
|
|
|
Well, just like the topic said.
I read some articles on this site but it's written in C++.
Thx.
|
|
|
|
|
Help
I have 2 user controls on a windows form (i am using C#) frmMyForm.
UserControl1.cs has 2 radiobuttons (rad1 & rad2)
UserControl2.cs has 2 labels (lbl1 & lbl2) which are hidden(visible = false)
I need to show lbl1 when rad1 is clicked and lbl2 when rad2 is clicked.
would appreciate if somebody would help me.
thanks
:
|
|
|
|
|
Call an EventHandler in UserControl1, if a radiobutton is clicked.
The delegate and event arguments:
public delegate void RadioClickEventHandler(object sender, RadioClickEventArgs e);
public class RadioClickEventArgs : EventArgs {
private int radioButtonIndex;
public String RadioButtonIndex{
get{ return radioButtonIndex;}
}
public RadioClickEventArgs(int radioButtonIndex){
this.radioButtonIndex = radioButtonIndex;
}
}
Somewhere in UserControl1:
internal event RadioclickEventHandler RadioClick;
if(RadioClick != null){
RadioClick(this, new PhoneCallEventArgs(telefonNummer));
}
Somewhere in the main form:
userControl1.RadioClick += new RadioClickEventHandler(this.userControl1_RadioClick);
_________________________________
Vote '1' if you're too lazy for a discussion
|
|
|
|
|
Hello All,
Problem Description,
I have a byte array in RGB form and created a bitmap using this byte array and was able to store it to hard disc as .bmp file.
Code for this:
IntPtr pIntData = Marshal.AllocCoTaskMem(aNewSize); //aNewSize = size of RGB array
Marshal.Copy(aTranslatedPixels, 0, pIntData, aNewSize); //aTranslatedPixels = RGB array
Bitmap pBitMap = new Bitmap(Columns, Rows , Columns * 3, System.Drawing.Imaging.PixelFormat.Format32bppRgb, pIntData);
Now I want to create a Icon from this Byte array, what steps should I be following for this?
Thank you for your help
Uday
|
|
|
|
|
i have recently started using gdi+.i integrated some gdi +code with existing mfc graphics code..smthg like
graphics g(hdc);
..
SetSmoothingMode(SmoothingModeAntiAlias);
and then drawing some simple curves and lines
g.drawline
g.drawcurve
....
..what happens is the first time the first draw fn(in this case drawline) takes a delay abt 500 ms..
same is the case when i try with sample proj..why does this occur??
|
|
|
|
|
Your question belongs in the Managed C++ Forum[^], not C#. C# doesn't support MFC.
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
Hi all,
I would like to write a C# Client-Server application, using Socket class (Not NetworkStreams or else)...
My problem is that I want to handle messages with unknown size... my server application uses a fixed-size receiving buffer (1024 bytes)... If I start flooding the server with small messages (let's say 20 bytes), server will store all the messages in the buffer with the same receive call... And I don't know how to recognize every message... I thought an end-tag would be a good idea, but since in the buffer could be every kind of data, I don't know if the tag could be a part of the message... if so, there could be decoding problems (if more than one message in the receiving buffer)... I thought about a start-tag and end-tag... but the problem remains... moreover this would increase too much packet length...
any suggestion?
|
|
|
|