|
Hi!
Set the property RowHeaderVisible of the datagrid to false.
HTH
|
|
|
|
|
Beginners question.
How do I pass listbox control to a class method and obtain access to the .items collection?
Can you point me to some sample code?
Thanks.
|
|
|
|
|
You would pass a reference to the control the same way you'd pass any variable to a method as a parameter:
void ClearList(ListBox listBox)
{
listBox.Items.Clear();
}
void Example()
{
ListBox listBox = new ListBox();
ClearList(listBox);
}
This posting is provided "AS IS" with no warranties, and confers no rights.
Software Design Engineer
Developer Division Customer Product-lifecycle Experience
Microsoft
[My Articles] [My Blog]
|
|
|
|
|
Hi, i was trying to retrieve information about the status of the battery, and to access the properties i tried to create an instance like the following:
PowerStatus bat = new PowerStatus();
But the error that i receive is that the class PowerStatus doesn't have a constructor defined and when i checked the class it doesn't have the constructor like other classes, you know the one called "PowerStatus()",so i´m wondering: am i doing something wrong?? or is a problem of the .NET Framework 1.1 ??cause i tried different ways to declare the same thing
I appreciate your help
|
|
|
|
|
|
As Christian said, if it doesn't declare a public default constructor you can't instantiate it using the void parameter list. The PowerStatus class in .NET 2.0 does declare any public constructor, actually, meaning that you can't instantiate it.
According to the documentation, you can obtain a reference to it using the static SystemInformation.PowerStatus property:
PowerStatus status = SystemInformation.PowerStatus;
Console.WriteLine("Battery life remaining: {0}",
status.BatteryLifePercent == 255f ? "Unknown" : status.BatteryLifePercent);
This posting is provided "AS IS" with no warranties, and confers no rights.
Software Design Engineer
Developer Division Customer Product-lifecycle Experience
Microsoft
[My Articles] [My Blog]
|
|
|
|
|
Hi,
I'm building an app in C#. It's a Windows App and it needs this common functionality ( we probably get to see in many windows apps ) where the user can keep on pressing the "Next" button when he finished entering a certain amount of data to go to the next level / display different controls.
The situation Im trying to explain is similar to a Setup program that executes an installation, while you keep on pressing the "Next" button.
So how can i achieve this in C# ? I know that in Java there are several Layout Managers like Card Layout to handle this type of situations. The only way possible I think is to add all the controls to be displayed in each step to a collection of Panels and then toggle their visibilty as needed.
But isnt there any easier way like in Java to get the job done ?
Thanx in advance !
|
|
|
|
|
If you want to show a whole lot of different screens, then I don't see a simpler way of doing it than creating panels as seperate user controls, then adding them all to your form. I'd put the page names into an array, the pages into a hash table by name, and add methods for go forward and backwards that look up the right panel to make visible, if you call an internal method that's a lot easier than trying to hide all panels but one in a lot of different places.
Christian Graus - Microsoft MVP - C++
|
|
|
|
|
www.codeproject.com/cs/miscctrl/magicwizard.asp
The Magic tool kit has a fairly easy to use wizard you might want to look at....
|
|
|
|
|
You should post this as a response to the original poster, so he gets an email notification of it.
Christian Graus - Microsoft MVP - C++
|
|
|
|
|
www.codeproject.com/cs/miscctrl/magicwizard.asp
The Magic tool kit has a fairly easy to use wizard you might want to look at....
|
|
|
|
|
Thank you very much guys !
I looked up the Magic Wizard code project. I think thats more inline with my requirement. I actually do not hav the time to go thru it now, but when i get back home Ill take a look at it and say how well it suits my purpose, as well as .NET's work around for such a situation.
And also, it jus struck me that my original solution ( the panel collection ) is not that feasible, cos it would take up some memory overhead wudn't it ?
Thanx again guys , sorry for this late and hasty response.
|
|
|
|
|
Can someone please help me with creating a loop to read from an Xml file into a jagged array.
The Xml file looks like this:
<test>
<problem type = "multichoice" elnumber = 8>
<question ID = 1>This is the question text</question>
<answer1>this is answer A</answer1>
<answer2>this is answer B</answer2>
<answer3>this is answer C</answer3>
<correct>answer2</correct>
<explanation>this is why</explanation>
</problem>
<problem type = "dragndrop" elnumber = 4>
<question ID = 2>This is the question text</question>
<explanation>this is why</explanation>
</problem>
Im using a jagged array because each question will have a different number of elements as shown above.
Can anyone suggest a good way to tackle this? An example code or structure would be appreciated. Thanks.
|
|
|
|
|
Just select all root nodes for questions, then for each one, iterate through the subnodes using a for...each, or another xpath if you just want the questions, and then build each array that way.
Christian Graus - Microsoft MVP - C++
|
|
|
|
|
Ok, thanks I'll try that.
|
|
|
|
|
I assume im to use the XmlDocument Class as opposed to the XmlTextReader class.
I can select the root nodes by using:
XmlNodeList rootList = doc.GetElementsByTagName("problem");
foreach(XmlNode node in rootList)
....
How do I go about retrieving the child nodes? Do i use another XmlNodeList for the child nodes and then build the array within this loop?
Sorry Im new to reading Xml files and was using XmlTextReader initially.
I searched all over for documentation on how to read a Xml document into an array. But I can't find any examples that are similar to what I want to achieve. Any chance you could give me some example code??
Thanks.
|
|
|
|
|
It's a shame you're using Access, as SQL Server or MSDE would just generate XML for you.
foreach(XmlNode node in doc.SelectNodes(@"//problem"))<br />
{<br />
foreach(XmlNode subNode in node.ChildNodes) <br />
{<br />
}<br />
}
Christian Graus - Microsoft MVP - C++
|
|
|
|
|
I'd like to write an Internet cafe program which has Address filter function. I want it like this: when user type something in the address bar of Internet Explorer window and press enter, the entered string will be sent to my program prior to IE itself, so I can manage bad addresses. What should I do?
|
|
|
|
|
|
I seriously doubt anyone is going to install software on their machine just to use your Internet Cafe. Your better bet is to use a firewall that already does this for you. What do you think corporations use?
On top of that, you've got a nightmare of a job trying to figure out what a "good" address is and what a "bad" one is.
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
Greetings,
I am using the PlaySound methode as specified below.
However, It always defaults to the default windows sound
regardless of where I place the file and the path I specify.
Here's the code snippit:
ussing System.Runtime.InteropServices;
namespace MySound {
public class Sound {
[DllImport("winmm.dll")]
public static extern bool PlaySound(string filename,long hmodule, int dword );
// To play the sound, I use:
Sound.PlaySound("BorderLine.wav",0,0x0001|0x0002|0x00020000);
Thanks,
--
Magela
|
|
|
|
|
This site has good info on working out proper pinvoke calls, and the URL is to the page on PlaySound.
http://www.pinvoke.net/default.aspx/winmm/PlaySound.html[^]
Also, is BorderLine.wav in the same folder as your exe ? Have you tried a full path ? Either way, there is another problem, as 2 is the flag to not play the default sound.
Christian Graus - Microsoft MVP - C++
|
|
|
|
|
Your problem is that the second parameter should be declared as an IntPtr , which is a 32-bit integer in 32-bit Windows and a 64-bit integer under 64-bit Windows (not under the WOW64 subsystem). This is the size of a pointer, which an HMODULE (in the native declaration) is.
A long (System.Int64 ) is always 64 bits. So, unless this only runs on 64-bit Windows as a 64-bit application (support for which starts in .NET 2.0 when compiled with the right flags) your parameters are pushed onto the stack (or into registers, since .NET uses FastCall by default) incorrectly. The third parameter would always be zero because the low-order bits would not be read by the callee (PlaySound ).
This posting is provided "AS IS" with no warranties, and confers no rights.
Software Design Engineer
Developer Division Customer Product-lifecycle Experience
Microsoft
[My Articles] [My Blog]
|
|
|
|
|
Good day all.
I have a two column Listview. The first column I would like to make readonly (I do not want the user to make changes to the content). The second column (Listviewitem sub) I would like the user to be able to make modification to it contents. Has anyone experienced or have written code to handle this type of solution.
Thank you in advance for you assistance.
|
|
|
|
|
That is not the best solution ,but it's easier,You can make your control a data grid,an make teh row read only and the other not,it will be likely for you.
|
|
|
|