|
the classes are not relevant, it is the array initialisation that you miss understand
When you create an array of objects, ie
cInput[] m_bInputs;
and then say
m_bInputs = new cInput[2];
you create an array, not a list of the objects
You need to call initialise after the new to call the default constructor.
What would be better tho is if you are using .NET 2.0 then use a list not an array, ie
List<cInput> inputs = new List<cInput>();
This way you will avoiding boxing ect ect
-- modified at 9:08 Friday 27th July, 2007
|
|
|
|
|
Please escape generics, else it wont show
|
|
|
|
|
But should each element of the array not be of type cInput?
For example if I was to make a integer array:
<br />
int[] IntArray;<br />
IntArray = new int[2];<br />
This would be OK. But while the following compiles and builds there is nothing in the array and so the call to the member function of cInput fails:
<br />
cInput[] bInputs;<br />
bInputs = new cInput[2];<br />
bInputs[0].m_SetState(true);<br />
I thought that bInputs would be a reference to the first element in the array, which happens to be an array of my user defined type, cInput.
Since I am not using .NET 1.0 is there another way around this...?
Cheers
Rich
|
|
|
|
|
I think you have missed my point!
An array in .NET is nothing like C++ or VB.
It is an Array object, a collection, NOT a series of memory locations initialised as a standard array.
I would suggest you do some more reading regarding collections, it is pretty important.
But to give you a head start, when you create an array here, you are actually creating a list of reference variables, and not that actual objects themselves, so, you will still need to call new on each location!
For example
<br />
cInput[] bInputs;<br />
bInputs = new cInput[2];<br />
<br />
for(int i = 0; i < bInputs.Length; i++)<br />
{<br />
bInputs[i] = new cInput();<br />
bInputs[i].m_SetState(true); <br />
}<br />
I would also suggest hwever, that if you are using .NET 2.0 or newer, look at and learn generics (again, look at the collections)
Paul.
|
|
|
|
|
Hi,
I need to retrieve local settings (country) of windows installation.
have any ideas?
thanx
|
|
|
|
|
Use the CultureInfo object in the System.Globalization namespace. It contains the default country settings. You can also use this class to set country settings for your application if you wish...
|
|
|
|
|
Thank you very much.
That was fast
|
|
|
|
|
hi frnds,
i have highligheted some rows in datagrid.
But when i click(right click) on any of them then other highlighted rows gets unhighlighted.
Give me any solution, U have......
Thanx........
Nisar Inamdar.
|
|
|
|
|
How to enable or disable a cell in DataGridView?
|
|
|
|
|
On ItemDataBound event
Write code for disable
ex//
e.Item[ColNum].Enable=false;
Best Regards,
Chetan Patel
|
|
|
|
|
Hello,
I am trying to run an .exe from my windows application. So I have this screen that when loaded, it creates a Process object and runs an .exe, captures the log file and writes it on a TextBox on the UI. The windows Form also has a [Stop] Button where it will terminate the Process when pressed.
My problem is that as I run the .exe, the main application hangs that it's almost impossible to press the [Stop] button. In the application though, I can still see the log file being captured and printed on the text box, but the [Stop] button just won't click.
I tried setting the Process ' Priority to BelowNormal but the problem was not solved.
Any suggestions?
Thanks!
Rafferty
|
|
|
|
|
Hello,
Rafferty Uy wrote: captures the log file and writes it on a TextBox on the UI
Wild guess:
You have to invoke the method which does this!
All the best,
Martin
|
|
|
|
|
You'd have to confirm with your code, but my wild-ass guess is that you're monitoring the process's output on your UI thread. Hence, it's not processing window messages, so it never sees the click on the Stop button.
You need to move the monitoring to a different thread, and use Invoke/BeginInvoke to send the text back to the UI thread to update the text box. .NET Framework 2.0 will throw exceptions if you try to modify a Windows Forms control from the wrong thread, when debugging; .NET Framework 1.x will not, but it's still an error.
|
|
|
|
|
Hi ,
How can I convert struct like this to array byte
public struct Message
{
public byte id;
public int value1;
public int value2;
public byte chkSum;
}
Not in this way :
public void converter()
{
Message message;
message.id = 1;
message.value1 = int.MaxValue ;
message.value2 = int.MaxValue ;
message.chkSum = (byte)(message.id +
message.value1 +
message.value2) ;
byte [] dataToSend = new byte [10];
dataToSend[0] = message.id ;
byte [] dataToInsert = BitConverter.GetBytes (message.value1 );
Array.Copy(dataToInsert, 0, dataToSend, 1, dataToInsert.Length);
dataToInsert = BitConverter.GetBytes(message.value1);
Array.Copy(dataToInsert, 0, dataToSend, 5, dataToInsert.Length);
dataToSend[9] = message.chkSum ;
}
thank you
|
|
|
|
|
Perhaps one way is to use a pointer ? You can set up a struct so that you specify how the bytes are laid out.
Christian Graus - Microsoft MVP - C++
"I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )
|
|
|
|
|
If you don't want that, what do you want then? What should the result be?
---
single minded; short sighted; long gone;
|
|
|
|
|
<FONT color=Blue>using</FONT> System<FONT color=DarkBlue>;</FONT>
<FONT color=Blue>using</FONT> System<FONT color=DarkBlue>.</FONT>Runtime<FONT color=DarkBlue>.</FONT>InteropServices<FONT color=DarkBlue>;</FONT>
<FONT color=Blue>namespace</FONT> ConsoleApplication9
<FONT color=DarkBlue>{</FONT>
<FONT color=Blue>class</FONT> <FONT color=Teal>Program</FONT>
<FONT color=DarkBlue>{</FONT>
<FONT color=DarkGreen>
<FONT color=DarkBlue>[</FONT><FONT color=Teal>StructLayout</FONT><FONT color=DarkBlue>(</FONT><FONT color=Teal>LayoutKind</FONT><FONT color=DarkBlue>.</FONT>Sequential<FONT color=DarkBlue>,</FONT> Pack<FONT color=DarkBlue>=</FONT><FONT color=Red>1</FONT><FONT color=DarkBlue>)</FONT><FONT color=DarkBlue>]</FONT>
<FONT color=Blue>public</FONT> <FONT color=Blue>struct</FONT> <FONT color=Teal>Message</FONT>
<FONT color=DarkBlue>{</FONT>
<FONT color=Blue>public</FONT> <FONT color=Blue>byte</FONT> id<FONT color=DarkBlue>;</FONT>
<FONT color=Blue>public</FONT> <FONT color=Blue>int</FONT> value1<FONT color=DarkBlue>;</FONT>
<FONT color=Blue>public</FONT> <FONT color=Blue>int</FONT> value2<FONT color=DarkBlue>;</FONT>
<FONT color=Blue>public</FONT> <FONT color=Blue>byte</FONT> chkSum<FONT color=DarkBlue>;</FONT>
<FONT color=DarkBlue>}</FONT>
<FONT color=Blue>static</FONT> <FONT color=Blue>unsafe</FONT> <FONT color=Blue>void</FONT> Main<FONT color=DarkBlue>(</FONT><FONT color=Blue>string</FONT><FONT color=DarkBlue>[]</FONT> args<FONT color=DarkBlue>)</FONT>
<FONT color=DarkBlue>{</FONT>
<FONT color=Teal>Message</FONT> m <FONT color=DarkBlue>=</FONT> <FONT color=Blue>new</FONT> <FONT color=Teal>Message</FONT><FONT color=DarkBlue>(</FONT><FONT color=DarkBlue>)</FONT><FONT color=DarkBlue>;</FONT>
<FONT color=Blue>int</FONT> size <FONT color=DarkBlue>=</FONT> <FONT color=Blue>sizeof</FONT><FONT color=DarkBlue>(</FONT><FONT color=Teal>Message</FONT><FONT color=DarkBlue>)</FONT><FONT color=DarkBlue>;</FONT>
<FONT color=Blue>byte</FONT><FONT color=DarkBlue>[]</FONT> output <FONT color=DarkBlue>=</FONT> <FONT color=Blue>new</FONT> <FONT color=Blue>byte</FONT><FONT color=DarkBlue>[</FONT>size<FONT color=DarkBlue>]</FONT><FONT color=DarkBlue>;</FONT>
<FONT color=Blue>byte</FONT><FONT color=DarkBlue>*</FONT> p <FONT color=DarkBlue>=</FONT> <FONT color=DarkBlue>(</FONT><FONT color=Blue>byte</FONT><FONT color=DarkBlue>*</FONT><FONT color=DarkBlue>)</FONT><FONT color=DarkBlue>&</FONT>m<FONT color=DarkBlue>;</FONT>
<FONT color=Blue>for</FONT> <FONT color=DarkBlue>(</FONT><FONT color=Blue>int</FONT> i <FONT color=DarkBlue>=</FONT> <FONT color=Red>0</FONT><FONT color=DarkBlue>;</FONT> i <FONT color=DarkBlue><</FONT> size<FONT color=DarkBlue>;</FONT> i<FONT color=DarkBlue>++</FONT><FONT color=DarkBlue>)</FONT>
<FONT color=DarkBlue>{</FONT>
output<FONT color=DarkBlue>[</FONT>i<FONT color=DarkBlue>]</FONT> <FONT color=DarkBlue>=</FONT> p<FONT color=DarkBlue>[</FONT>i<FONT color=DarkBlue>]</FONT><FONT color=DarkBlue>;</FONT>
<FONT color=DarkBlue>}</FONT>
<FONT color=Teal>Console</FONT><FONT color=DarkBlue>.</FONT>ReadLine<FONT color=DarkBlue>(</FONT><FONT color=DarkBlue>)</FONT><FONT color=DarkBlue>;</FONT>
<FONT color=DarkBlue>}</FONT>
<FONT color=DarkBlue>}</FONT>
<FONT color=DarkBlue>}</FONT>
|
|
|
|
|
Use Serialization ? If the client is using .net
|
|
|
|
|
Hello Friends
I have one problem regrading mail. in my system i, there is reqrment to attech perticular file and sent it to client. so that i have to use outlook and mailto option
For that reason i am using
System.Diagnostics.Process.Start("mailto:dhaval@yahoo.com?body=hello&subject=hi&attachment=c:\\hello.gif");
My problem is that everything work fine but attechment create some problem for me.
In outlook window i have not any attechment
Please Give me som guideline..
Happy programming.................
|
|
|
|
|
You can use MAPI, but I don't think you can send an attachment with a mailto
Christian Graus - Microsoft MVP - C++
"I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )
|
|
|
|
|
Dear fellows
I have problem about which i donot from where i can get help.
What is Working:
I have made a ASP.NET (C#) application that is reading Data from Excel (cell b cell). That is working fine and i can check it in browser.
Problem:
Now using this code i made a web part in C# and i want to show it in SharPoint Server 2007 site page. Now that is not working , thats mean not showing the web part on the page.
And when i comment the excel ralated code in web part coding and check it at SharePoint server, web part works.
I donot know what to do, Please Help
Thanks
Asif khan
|
|
|
|
|
Hi All,
I want to find find all the device around my PC or Device, How can i do that
i broadcast message, all client around for responding but not able to collect all the message
plz help me to find the answer
With Regards
Amjath
|
|
|
|
|
Hello,
In .Net < 2.0 you have to use System.Management functionalities.
ArrayList drives = new ArrayList();
using(ManagementObjectSearcher DriveSearch = new ManagementObjectSearcher(new SelectQuery("Select * from Win32_LogicalDisk")))
{
using(ManagementObjectCollection moDriveCollection = DriveSearch.Get())
{
foreach(ManagementObject mo in moDriveCollection)
{
LogicalDriveInfo driveinfo = new LogicalDriveInfo(mo);
if(this[driveinfo.Name] == null)
drives.Add(driveinfo);
mo.Dispose();
}
}
}
For .Net >= 2.0 you could use DriveInfo.GetDrives()[^]
All the best,
Martin
|
|
|
|
|
Hi Martin,
Thanks for ur valuable inputs.
i will explain in detail wat i want, i have 1 details connected to my pc that device associate to many wireless clinet, i want get the information abt that wireless devices,
how can i do that
With Regards
Amjath
|
|
|
|
|
Does anyone have a simple example or steps on how to print a datagrid with paging and sorting? I would like to attach the function to a button control on the form and then once clicked send the entire datagrid with whole data to the printer
sameer Gupta
|
|
|
|