|
Dear Sir/Madam
i want to compare two different datagridview with same column name with different row count.
i want to compare both and fine row count (how much row not exist in second datagridview) and row which is not ixist in second datagridview into array or its display on third seprate datagridview.
please help me to find solution as soon as possible.
|
|
|
|
|
What have you tried so far?
Where are you stuck?
What help do you need?
Bad command or file name. Bad, bad command! Sit! Stay! Staaaay...
|
|
|
|
|
How are the datagrids populated? I am assuming they are built with a List<object>? Also if the object in the list has a field name, then foreach on both lists and compare a field like name.
foreach (CustomObject a in list1)
{
if (!list2.Contains(a))
{
notIncludedList.Add(a);
}
}
int num = notIncludedList.count;
Like Griff pointed out, we really don't have a lot to go on, so can you be more specific with what code you have that is not working, or give us a small snipet so that we can see what you are working with and help to resolve it?
|
|
|
|
|
My suggestion is to compare the (records of the) "data sources" instead of trying to compare "grids".
|
|
|
|
|
Hello,
I am new to C# programming, I am doing Mini project on Apriori Algorithm using C# and I don't know from where I should start. Any one who willing to give me a guide to implement it and sample source code. I appreciate your help .
Thanks.
|
|
|
|
|
|
For me, debugging challenges are both the best and the worst experiences in programming; this one is a challenge I can "relish," since there's no deadline, no paycheck-on-the-line
I have a complex class that I serialize and de-serialize using WCF [DataContract] and [DataMember] Attributes without errors, or warning. In the test I've constructed to validate de-serialization are some Linq queries that when run against the de-serialized class instance come up with unexpected null results.
It appears I have Linq queries which give different results given identical inputs from which I assume, of course, that the problem is something subtle.
Here's an example of a query where the unexpected behavior (null result) is observed:
public IEnumerable<Relationship> GetRelationships(string n1, string n2)
{
Node fromNode = NameToNode[n1];
Node toNode = NameToNode[n2];
return
Relationships.Where(r => r.EndNode == fromNode && r.StartNode == toNode)
.Concat
(
Relationships.Where(r => r.StartNode == fromNode && r.EndNode == toNode)
);
}
var rels = testGraph.GetRelationships("gina", "harry"); What is puzzling is that some Linq queries work fine, like this one:
var wholikesjim = testGraph.Relationships.Where
(rel => rel.Name == "Likes").Where(rel => rel.EndNode.Name == "jim"
); So far, I've done this:
0. (the obvious) inspected the serialized xml for "weirdness."
1. created a method to write all the various objects and their values to a TextBox, then compared the run-time report of the "native" version of the class instance to the de-serialized instance. The outputs are identical.
2. drilled down at run-time into the class instance using the debugger at the places where unexpected behavior occurs and noted the existing values/state of the various sub-objects when Linq queries are performed, then compared those before and after serialization/de-serialization.
The other queries which are not performing all use 'Join.
I'm stumped; I'll appreciate your ideas.
«I want to stay as close to the edge as I can without going over. Out on the edge you see all kinds of things you can't see from the center» Kurt Vonnegut.
|
|
|
|
|
In the queries that work, you are comparing "strings" (values).
In the ones that don't work, you appear to be comparing "object references" (unless there is an overloaded operator at work somewhere).
|
|
|
|
|
Valuable insight, Gerry,
Last night I had written an overloaded == operator for the Node Class, and that fixed one query, and just this morning (GMT +07 here), I rewrote (using foreach so I could inspect the internal state) one of the Linq queries that still doesn't compare Node instances consistently after the class is de-serialized.
As you suggest, I found the expected equality comparisons were not as expected.
The conclusion I reach is that after de-serialization what should be two references to the same Class instance are, in fact, references to two distinct Class instances that have identical properties.
So, today I will try and discover how that came to be.
thanks, Bill
«I want to stay as close to the edge as I can without going over. Out on the edge you see all kinds of things you can't see from the center» Kurt Vonnegut.
|
|
|
|
|
Yes; curious ... one usually needs to take deliberate steps in order to clone another object; particularly if a deep clone is required.
(Except when there's a systemic anomaly in the matrix).
|
|
|
|
|
I'm kind of curious here. When are you interested in calling a clone to get a shallow copy? Id just create a pointer instead then, wouldn't you?
In making a deep copy always end up doing this:
Class MyClasss
Implements ICloneable
Private pName As String
Public Property Name() As String
Get
Return pName
End Get
Set(ByVal value As String)
pName = value
End Set
End Property
Private pNAmes As New List(Of String)
Public Property Names() As List(Of String)
Get
Return pNAmes
End Get
Set(ByVal value As List(Of String))
pNAmes = value
End Set
End Property
Public Function Clone() As Object Implements ICloneable.Clone
Dim result As New MyClasss
result = Me.MemberwiseClone
' If I have any properties of collection type
' I need to create a copy of each list
Dim TempNames As New List(Of String)
For Each str As String In Names
TempNames.Add(str)
Next
result.Names = TempNames
Return result
End Function
End Class
But I would sure like to know why the MemberwiseClone can't clone lists or collections like this. I also bet there is a more generic way of implementing it though.
|
|
|
|
|
I think you'd benefit by posting this as a separate question.
cheers, Bill
«I want to stay as close to the edge as I can without going over. Out on the edge you see all kinds of things you can't see from the center» Kurt Vonnegut.
|
|
|
|
|
I tend to use shallow copies in my CRUD operations when I'm not interested in creating an entire graph of objects and just need access to one object's instance values: e.g. for change tracking / undoing changes; creating and initializing binding sources; etc.
A reference to an existing object used for another purpose would not work in this case.
I suspect MemberwiseClone() is only intended to be a primitive for shallow copies because there are a number of ways to do deep copies, including reflection and serialization / deserialization:
static object Clone( object parent ) {
XmlSerializer serializer = new XmlSerializer( parent.GetType() );
object clone = null;
using ( MemoryStream stream = new MemoryStream() ) {
serializer.Serialize( stream, parent );
stream.Position = 0;
clone = serializer.Deserialize( stream );
}
return clone;
}
|
|
|
|
|
I like the serialization/deserialization methodf as I'm often also interested in saving classes to file, but I cant help by feeling that it's a bit strange. If I say clone this class; I would think it would be easy to say, just create an exact independent copy of this class.
I also found a good description of the pro/cons of the different ways to clone a class:
http://developerscon.blogspot.no/2008/06/c-object-clone-wars.html[^]
As for the MemberwiseClone method, I don't really know the story behind it, but I seem to remember that it would give you an error in the previous versions of .NET (2.0?), If you tried to access a property of collection type. Now it just gives you a pointer to the original class.
I also realized that Bill was right. Should have started a new thread, but I just wondered what people did, so It didn't feel like a 'real' question.
|
|
|
|
|
only type the integer value in the text box,in case type any float value or character value means create a label than indicate "the value is not to integer format".c sharp windows application it's all under in one
modified 24-Sep-15 12:58pm.
|
|
|
|
|
See this[^] post (assuming you're talking WinForms).
Member 11982934 wrote: plz help me it's urzent Not to me, it isn't. Remember, CP is staffed by volunteers who take time out of their day to help others. Marking a question "urgent" doesn't reduce the urgency of my own job.
/ravi
|
|
|
|
|
|
I have to agree with Ravi - I checked with everybody here and it's not on anybodies top 100 "things to do today" list. So it's not urgent at all, and I'll get round to it one day. Real soon, probably. Well, maybe soon. Could be Christmas...
Bad command or file name. Bad, bad command! Sit! Stay! Staaaay...
|
|
|
|
|
Only allow digits in the TextBox (use a mask and / or an event handler) ... This avoids the whole question of whether it is an integer, float, negative, etc.
|
|
|
|
|
Hi, I have inherited UserControl to MySubControl to add a common core base for a new set of controls.
However, when events are added in VS2013 designer, MyControl the events attached to MYControl do not fire.
i.e.
this.MyControl = new MySubControl .MyControl ();
this.MyControl .Load += new System.EventHandler(this.MyControl );
Can anyone point me in the right direction..
Thanks
public class MySubControl : UserControl
{
}
public partial class MyControl : MySubControl
{
}
|
|
|
|
|
Um...that's some odd code. Does it compile?
Normally, you would add the handler by pointing at a method - not at an instance.
Bad command or file name. Bad, bad command! Sit! Stay! Staaaay...
|
|
|
|
|
A 'Load EventHandler in an inherting UserControl, created at design-time, or run-time in code ... will work.
A 'Load EventHandler in a UserControl named 'MyControl which inherits from a UserControl, 'MySubControl will fire after you have created an instance of 'MyControl by:
1. design-time: drag-drop from ToolBox to a Form or other Container Control
or
2. run-time: you have created an instance in code
And you then execute your program.
To help you beyond this, I think we need more details from about what you are doing.
Please show code that you are using that demonstrates what you describe.
Are you only creating instances of 'MyControl ?
«I want to stay as close to the edge as I can without going over. Out on the edge you see all kinds of things you can't see from the center» Kurt Vonnegut.
|
|
|
|
|
A user control still needs to be added to a Window's .Controls collection before it will display (in a Window) and fire the .Load event.
|
|
|
|
|
That's an excellent point to stress, Gerry !
«I want to stay as close to the edge as I can without going over. Out on the edge you see all kinds of things you can't see from the center» Kurt Vonnegut.
|
|
|
|
|
Thanks for the response guys, I have sorted it now.
I had a sendmessage in an area of code which seemed to block all events from firing back. Moved to somewhere more sensible.
|
|
|
|