|
Thanks jkersch,
1.
My question is, I have read through here,
http://msdn.microsoft.com/en-us/library/ms733133.aspx[^]
but it does not contain any description about how to use namespace information of the remote WCF service, do you have any samples or documents to refer to me about how to utilize namespace from client side?
2.
How namespace information is used at server side?
regards,
George
|
|
|
|
|
Hi,
How can set focus to one particular row in the DataGridView?
(I want to trigger a event like button_click or whatever)
What is the propriety for that?
nelsonpaixao@yahoo.com.br
|
|
|
|
|
Hi nelsonpaixao,
You may try this - YourDataGridView.Rows[rowindex].Selected = true .
Hope this help.
regards
cocoonwls
|
|
|
|
|
thanks i will chect that
nelsonpaixao@yahoo.com.br
|
|
|
|
|
Tonight I came accross an issue when using a Find method on a collection where I needed to idealy null test an item in the collection. The problem was the collection was a List of struct - and structs can't be null!
I got round it by testing a property in the struct (which was a class so null was possible).
I 'googled' and found this[^] interesting solution. Just wondered what the experts here thought about it?
DaveBTW, in software, hope and pray is not a viable strategy. (Luc Pattyn)
|
|
|
|
|
A couple of thoughts. If null is a valid state for an element of the collection, then shouldn't the collection be declared for example:
struct myStruct { ... }
List<myStruct?> list;
Alternatively you could define an empty state for myStruct and compare against that, in the same way that Point or Size work, for instance.
I'm largely language agnostic
After a while they all bug me
|
|
|
|
|
It would be much easier to make it nullable.
In C# 2.0 onwards, to create a nullable struct declare it like this:
int? myNullableInt = null;
Note the question mark after the type name. This indicates that it is actually a nullable int, and as you can see you can assign null to it.
So, to declare a list of nullable struct types, try something like this:
List<int?> myNullableIntList = new List<int?>;
|
|
|
|
|
That causes problems when trying to access properties of the struct but I get the idea!
DaveBTW, in software, hope and pray is not a viable strategy. (Luc Pattyn)Expect everything to be hard and then enjoy the things that come easy. (code-frog)
|
|
|
|
|
If you're trying to keep the check simple and elegant, you could try an approach of returning either the nullable item, or when null a default item, something similar to:
struct myStruct {
public bool IsValid;
public readonly myStruct Empty;
}
foreach(myStruct? item in collection) {
if((item ?? myStruct.Empty).IsValid) {
...
}
}
The ?? operator returns whats on the left if not null or else whats on the right.
I'm largely language agnostic
After a while they all bug me
|
|
|
|
|
It works when definining an object that way but not when derriving from List<struct>
See below[^]
DaveBTW, in software, hope and pray is not a viable strategy. (Luc Pattyn)Expect everything to be hard and then enjoy the things that come easy. (code-frog)
|
|
|
|
|
I'll second Colin's suggestion (use the Nullable type). I just thought I'd explain how it works, essentially the nullable operator (? ) in C# is syntatic sugar like LINQ which tells the compiler to change:
int? myInt;
Nullable<int> myInt; Nullable is a class defined in the System namespace and has two properties, Value and HasValue (almost exactly what you're suggesting implementing), however the operators are already implemented so for most cases you can forget you're dealing with a nullable type (just remember to perform null checks).
|
|
|
|
|
I think I get it - but how to make it work?
Consider this simple sample code:
public struct X
{
private string m_Property;
public string Property
{
get { return m_Property; }
set { m_Property = value; }
}
}
public class XCollection : List<X>
{
private bool ItemExists(string stringProperty)
{
X found = Find(item => item.Property == stringProperty);
return found.Property != null ? true : false;
}
}
Changing the collection class declaration to public class XCollection : List<X?> screws it up!
DaveBTW, in software, hope and pray is not a viable strategy. (Luc Pattyn)Expect everything to be hard and then enjoy the things that come easy. (code-frog)
|
|
|
|
|
Then put an additional check for null in the lambda expression
item => (item == null) ? false : item.Property == stringProperty
|
|
|
|
|
Also, your stuct is mutable, this will cause you additional problems because the instances of the struct are copied rather than referenced you may be making changes to a copy rather than the original and the functionality may not be desired.
You should make your struct immutable by removing any setters and methods that modify the internal state once it is created.
|
|
|
|
|
Thanks for the advice but I need the struct to be mutable in this situation.
DaveBTW, in software, hope and pray is not a viable strategy. (Luc Pattyn)Expect everything to be hard and then enjoy the things that come easy. (code-frog)
|
|
|
|
|
Then you would be better changing it to a class.
|
|
|
|
|
The struct could have a static member to use in that case, kinda like String.Empty and Guid.Empty
|
|
|
|
|
Doh! That hadn't crossed my mind - thanks
DaveBTW, in software, hope and pray is not a viable strategy. (Luc Pattyn)Expect everything to be hard and then enjoy the things that come easy. (code-frog)
|
|
|
|
|
I want to make a program to monitor the useage of my system,
In short a keylogger like program.
Now i don't know which method i should use,
I dont care for precision just performance.
So i use a timer then get the current active window and GetKeyboardState using getkeyboardstate does mean i wont have the correct order of letters but thats not really the point.
Or i could use a keyboard and mouse hook but im wondering if this is unstable for my system or has heavy workload which i dont really want.
So what should i do?
Thanks
|
|
|
|
|
Scalee wrote: I want to make a program to monitor the useage of my system,
In short a keylogger like program.
Why? Do you type in your sleep?
led mike
|
|
|
|
|
1) Convince us you're not trying to write malware
2) see )1
Today's lesson is brought to you by the word "niggardly". Remember kids, don't attribute to racism what can be explained by Scandinavian language roots.
-- Robert Royall
|
|
|
|
|
If i wanted to write malware then i would care about the order the letters where typed,
And i would give a crap about system stability because it wouldn't be my system.
And second why try to make a keylogger while you can download a ton online, So i hope this convinces you.
The reason why i want to create this is because i often leave my laptop unattended for a while at work and probably because im paranoid.
|
|
|
|
|
"Why try to make a keylogger while you can download a ton online" would then be my answer
|
|
|
|
|
|
I want to use the "SELECT " statement on DataTable, which fetches records between these 2 date ranges:
StartDate : 01-01-2007 and,
EndDate : 01-01-2008
The code is as follows:
if (newPDS.Tables[0].Columns["ADM_DATE"]== null)
{
DataColumn dCol = new DataColumn(newPDS.Tables[0].Columns.Add("ADM_DATE", typeof(DateTime), "").ToString());
}
for(Int32 i = 0; i < newPDS.Tables[0].Rows.Count; i++)
{
row = newPDS.Tables[0].Rows[i];
row["ADM_DATE"] = row["CADMMM"] + "/" + row["CADMDD"] + "/" + row["CADMHH"] + row["CADMYY"];
DateTime newDT = new DateTime();
newDT = Convert.ToDateTime(row["ADM_DATE"]).Date;
row["ADM_DATE"] = newDT.ToShortDateString();
string newQuery = "ADM_DATE between StartDate and EndDate";
newDR = myTable.Select(newQuery);
}
myReport.SetDataSource(newDR);
crystalReportViewer1.ReportSource = myReport;
Thanking you in anticipation.
modified on Tuesday, August 5, 2008 3:33 PM
|
|
|
|