|
|
XmlNode node = xml.SelectSinglenode(@"/Licenses/License[@HostName='SIN520APP190' and @IPAddress='192.168.1.2'] ");
try this out and c what happens
Rocky
|
|
|
|
|
Thanks Rocky..
xml.SelectSingleNode(@"/Licenses/License[@Att1='xx' and @Att2='xx'] works.
Problem was with my syntax, i was enclosing each attribute within square braces. God bless.
|
|
|
|
|
|
hi all,
i am using a datagridview and set the datasource to a datatable in my windows application. i added a datagridviewcheckboxcolumn representing status for each of my row.
I need to get the values of all rows where checkbox is selected.
i tried the following code
for (int i = 0; i < datagridview1.Rows.Count; i++)
{
DataGridViewCheckBoxCell cell = (DataGridViewCheckBoxCell)datagridview1.Rows[i].Cells[1];
if (cell.value.tostring() == "true")
{
MessageBox.Show(datagridview1.Rows[i].Cells[0].value.tostring());
}
}
if i have two rows in my datagrid, and if i checked both rows only the first row value is displayed. the second row value is not selected.the last row value is not displayed.
can anyone suggest me where i am going wrong? how to implement this?
Thanks in advance.
Regards
Anuradha
|
|
|
|
|
for (int i = 0; i < datagridview1.Rows.Count; i++)
{
if(Convert.ToBoolean(dataGridView[i/*rownum*/,ColumnIndex]) == true))
{
//do ur stuff and plz confirm whether the row index and column index are at right place
}
}
hope it helps
|
|
|
|
|
In my project I would like to have a code file that just stores the global variables I will be using.
I added a code file to the project, but i cant declare directly like this:
<br />
int ItemRecordLength = 252;<br />
int SkillRecordLength = 140;<br />
int CharacterRecordLength = 4540;<br />
int InventoryRecordLength = 44;<br />
int RemainingStatPoints = 35;<br />
Is it possible to do this? I want these variables to be usable from any class/form within the project. I hope i made the problem clear
Thanks
|
|
|
|
|
just make a new public class in a new file preferably and declare all thse variables as static. That should do the job for you
|
|
|
|
|
It's best to define them in a static class and use the const modifier, somethink like this:
public static class Constants
{
public const int MyInt = 48000;
Standards are great! Everybody should have one!
|
|
|
|
|
Wow, thanks for the quick replies guys.
I better go read up on static classes ^^
Cheers 
|
|
|
|
|
I forgot to mention, not all of these will be constants, many of them will be modified during runtime, can i still use a static class for that?
|
|
|
|
|
|
yes, but if you want to change them they cant be const .
|
|
|
|
|
Surely you can, but I'm no friend of static what-so-ever because most of the times usage of statics lead to a poorly designed project (but that depends on what you want to do, of course).
Issues of statics:
- Robustness against multi threading
- tight coupling of components or monolithic design (instead of loose coupling)
- all problems that singletons have
However, this is just a design consideration, not a technical problem
-^-^-^-^-^-
no risk no funk ................... please vote ------>
|
|
|
|
|
Also you may consider using property to make it neat.
modified 17-Jul-19 21:02pm.
|
|
|
|
|
Hi!
How do we retrieve all the installed softwares in WMI? All means all the softwares being installed in the computer. I used win32_Product yet it only retrieves those microsoft softwares and it even displays everything added to that software like an update.
The following are the needed information:
Softwarename
InstallDate
SotwarePath
AllotedLocationType
RegistryPath
ExecutableFilename
LastUsed
TotalUsageDurationMins
IsUninstalled
IsHotfix
IsServicePack
isUnauthorized
Please help.
Thanks.
-- modified at 7:18 Thursday 16th August, 2007
|
|
|
|
|
You can enumerate keys for path...
HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall
..and then look for DisplayName, UninstallString and other values as suited.
If you get to know a better way out please do let me know as well
Cheers
H.
|
|
|
|
|
Have a look at my response[^]. At the bottom of it is the WMI query against the Win32_Product class that you can use, it's much simpler than enumerating over the registry keys.
|
|
|
|
|
Using WMI isn't the simplest thing to do from managed code. If you search Google, you'll find a lot of information. Here is sample code from a message[^] in the microsft.public.dotnet.framework.wmi newsgroup:
const uint HKEY_LOCAL_MACHINE = unchecked((uint)0x80000002);
ManagementClass wmiRegistry = new ManagementClass("root/default", "StdRegProv", null);
string keyPath = @"SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall";
object[] methodArgs = new object[] {HKEY_LOCAL_MACHINE, keyPath, null};
uint returnValue = (uint)wmiRegistry.InvokeMethod("EnumKey", methodArgs);
Console.WriteLine("Executing EnumKey() returns: {0}", returnValue);
if (null != methodArgs[2])
{
string[] subKeys = methodArgs[2] as String[];
if (subKeys == null) return;
ManagementBaseObject inParam = wmiRegistry.GetMethodParameters("GetStringValue");
inParam["hDefKey"] = HKEY_LOCAL_MACHINE;
string keyName = "";
foreach(string subKey in subKeys)
{
keyPath = @"SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\" + subKey;
keyName = "DisplayName";
inParam["sSubKeyName"] = keyPath;
inParam["sValueName"] = keyName;
ManagementBaseObject outParam = wmiRegistry.InvokeMethod("GetStringValue", inParam, null);
if ((uint)outParam["ReturnValue"] == 0)
Console.WriteLine(outParam["sValue"]);
}
} This is essentially just enumerating over the HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\ registry key, so you can use the normal .NET registry classes to do the same thing without WMI.
Using the Win32_Product class, you would want to do something like this:
ManagementObjectSearcher products = new ManagementObjectSearcher("SELECT * FROM Win32_Product");
foreach (ManagementObject product in products.Get())
{
Console.WriteLine("Software name: {0}", product.Name);
Console.WriteLine("Install date: {0}", product.InstallDate);
...
} The properties you list aren't all included in the Win32_Product[^] class, so you will probably need to do additional queries against other objects to get all of the information.
|
|
|
|
|
how about if we will display the installdate and installlocation using the latter code? or using the registry?
if inParam["sValueName"] = keyName is used to get the Displayname, how about the rest of the values? like installdate, softwarepath and the rest of the values?
|
|
|
|
|
toink toink wrote: how about if we will display the installdate and installlocation using the latter code? or using the registry?
What code are you referring to here?
toink toink wrote: if inParam["sValueName"] = keyName is used to get the Displayname, how about the rest of the values? like installdate, softwarepath and the rest of the values?
It sounds like you would probably do better to use this
ManagementObjectSearcher products = new ManagementObjectSearcher("SELECT * FROM Win32_Product");
foreach (ManagementObject product in products.Get())
{
Console.WriteLine("Software name: {0}", product.Name);
Console.WriteLine("Install date: {0}", product.InstallDate);
...
}
|
|
|
|
|
Hi,
I have a DataGridView control with one column as ComboBox control.
I want to raise the event "SelectedValueChanged" of combo box.
How to do this. Please help.
Thanks & Regards,
nas
|
|
|
|
|
read an article on deploying events in C# applications over MSDN or search google.
write this line in your constructor.
dataGridView1.SelectedValueChanged+=<then press="" the="" tab="" key="" twice="" you'll="" get="" right="" thing="" in="" here="">then you start coding in the function made for the event handler
Rocky
|
|
|
|
|
Hi Rocky,
Thanks for reply.
Actually in DataGridView we can make any Column-Type as controls (Button,ComboBox, CheckBox...).
So i have selected one column of DGV as ComboBox. But this ComboBox differs from the normal ComboBox control.
By coding i want to access the ComboBox control of the DGV. 
|
|
|
|
|
OK
I know ur talking abt the datagridviewcombobox control right? try using the event 'CellValueChanged' on the dGV and in that you can get the column as
if(e.columnIndex == yourdgvcomboboxname.ColumnIndex)
{
//perform you task
}
and c if this things works for u or not incaseif it does give this msg and full rating
|
|
|
|