|
I have Dictionary that contain (key values)
I want to display it in Grid in WPF in one row only
I mean : make the key as Column name and the related value the field value
so how can i do that I think I need to Build Dynamic Class
by Reflection and convert the key value of the dictionary to Properties
after that initialize an object and fill its properties with values from
dictionary after that bind the object to the Grid .
is that right or is there any easier way ??
You have To Search About The Truth Of Your Life
Why Are you Here In Life ?
|
|
|
|
|
Hi,
I want to show a tooltip.
How to show a tooltip in Win Ce?
what a class and namespace is for it?
Or i must use a API function? what?
Thanks
|
|
|
|
|
Hi,
I did some tests and realized that multicast delegates are slower than a generic list of delegates.
Did i make a mistake or is this correct?
This is the code i used.
class MyObject {
const int childMax = 10;
const int runMax = 100000000;
Stopwatch SW = new Stopwatch();
event EventHandler MyEvent;
List<EventHandler> eventList = new List<EventHandler>();
Dictionary<string, EventHandler> eventDict = new Dictionary<string, EventHandler>();
int iterator = 0;
public MyObject() {
for (int i = 0; i< childMax ; i++ ) {
eventList.Add(MyFunc);
eventDict.Add(i.ToString(),MyFunc);
MyEvent += MyFunc;
}
}
public void Test() {
SW.Start();
for (int i = 0; i< runMax ; i++ ) {
MyEvent(null,null);
}
SW.Stop();
Console.WriteLine("Iterator=" + iterator.ToString("n") + " using Events, Elapsed: " + SW.Elapsed.ToString());
SW.Reset();
SW.Start();
for (int i = 0; i< runMax ; i++ ) {
for (int j = 0; j < childMax; j++) {
eventList[j](null,null);
}
}
SW.Stop();
Console.WriteLine("Iterator=" + iterator.ToString("n") + " using List, Elapsed: " + SW.Elapsed.ToString());
SW.Reset();
}
private void MyFunc(object sender, EventArgs e) {
iterator++;
}
}
This is the result on my machine (2,2 gHz)
Iterator=1.000.000.000,00 using Events, Elapsed: 00:00:06.2153030
Iterator=2.000.000.000,00 using List, Elapsed: 00:00:04.8695574
Press any key to continue . . .
|
|
|
|
|
Not much of an actual difference. Just bear it in mind and don't use an event when you don't need to.
"Use the right tool for the right job." -- Scotty, et al
|
|
|
|
|
Hi,
running same code on a slower CPU (Intel Atom N270) I get the opposite result:
100M iter: events=3.9s list=5.1s
Luc Pattyn [Forum Guidelines] [My Articles]
The quality and detail of your question reflects on the effectiveness of the help you are likely to get.
Show formatted code inside PRE tags, and give clear symptoms when describing a problem.
|
|
|
|
|
That's 14ns, yes nano seconds, difference per iteration.
I can't think of a real world situation that I've come across where that would be significant. I've certainly never had 100 million subscribers to an event!
Performance differences like this often exist but results can vary dramatically depending on other parameters such as hardware etc, and normally it is of no consequence anyway.
DaveBTW, in software, hope and pray is not a viable strategy. (Luc Pattyn) Visual Basic is not used by normal people so we're not covering it here. (Uncyclopedia) Why are you using VB6? Do you hate yourself? (Christian Graus)
|
|
|
|
|
Why Dave, there are over 6 million CPians reading your daily messages, plus an unknown number of anonymous people, aka non-members; you may not consider them subscribers but they are real. Don't put them down.
Luc Pattyn [Forum Guidelines] [My Articles]
The quality and detail of your question reflects on the effectiveness of the help you are likely to get.
Show formatted code inside PRE tags, and give clear symptoms when describing a problem.
|
|
|
|
|
I know CP has that many members, but it's only you saying that, that I've suddenly realised millions of people may read what I post... scary! Quite a resposibility really
DaveBTW, in software, hope and pray is not a viable strategy. (Luc Pattyn) Visual Basic is not used by normal people so we're not covering it here. (Uncyclopedia) Why are you using VB6? Do you hate yourself? (Christian Graus)
|
|
|
|
|
Hello all,
I have this nagging error which i have applied common knowledge to solve it but could not. in the code segment below, I want to be able to loop through a dataset to extract value, but i keep getting the error as metioned "object reference not set to an instance......". as u can c, the objects i used are instantiated, please can anyone help solve this problem?
Dim dset1 As DataSet
Dim dt As DataTable
dSet1 = New DataSet
'The adapter stores the data in a dataset
dAdapt1.Fill(dSet1, "Patient Profile")
dt = New DataTable
dt = dSet1.Tables("Patient_Profile")
For Each rw As DataRow In dt.Rows --> Error Object reference not set to an instance of an object.
decdata = New TripleDES()
deRecDataFnam = decdata.Decrypt(rw("FirstName"), ned)
listItem = New ListViewItem()
listItem.SubItems.Add(deRecDataFnam)
ListVwPatProf.Items.Add(listItem)
Next
Thanks a lot!
|
|
|
|
|
ChiSmile wrote:
dt = New DataTable
dt = dSet1.Tables("Patient_Profile")
Yes, you're indeed initializing dt , but then you're reassigning it the value of dSet1.Tables("Patient_Profile") . Make sure you actually have a table in dSet1 called Patient_Profile .
Adam Maras | Software Developer
Microsoft Certified Professional Developer
|
|
|
|
|
ChiSmile wrote: dAdapt1.Fill(dSet1, "Patient Profile")
ChiSmile wrote: dt = dSet1.Tables("Patient_Profile")
Do you see the problem there? Here's a hint - you've got a magic string issue - when you use a string in one place to name something, you've got to use the same name whenever you refer to it.
Now, here's a piece of advice - learn how to debug. If you had set a breakpoint and stepped over your code (pausing to explore the values as you were debugging), you'd have found this issue straightaway.
"WPF has many lovers. It's a veritable porn star!" - Josh Smith As Braveheart once said, "You can take our freedom but you'll never take our Hobnobs!" - Martin Hughes.
My blog | My articles | MoXAML PowerToys | Onyx
|
|
|
|
|
thank pete and Adams for ur help,it now works!.
Pete ur advice:
Now, here's a piece of advice - learn how to debug. If you had set a breakpoint and stepped over your code (pausing to explore the values as you were debugging), you'd have found this issue straightaway.
this is noted, but dont know how to do that. not that experieced though, will be glad if u show me. Thanks!
|
|
|
|
|
Put a breakpoint on dAdapt1.Fill(dSet1, "Patient Profile"). Run your code in debug mode and it will stop at this point - to "step over" the code (this means to execute your code a line at a time), press F10. If you want to step into a function, press F11 - if you have the pdb file, or the actual source.
To view the contents, you can view it in the locals window, add a quick watch, use one of the debugger visualizers or any one of a dozen other methods.
"WPF has many lovers. It's a veritable porn star!" - Josh Smith As Braveheart once said, "You can take our freedom but you'll never take our Hobnobs!" - Martin Hughes.
My blog | My articles | MoXAML PowerToys | Onyx
|
|
|
|
|
I'm working with a datagridview in Visual C# and one of the properties of this control keeps getting reset whenever I edit the GUI.
The following line appears in the source code:
//
this.dataGridView1.AutoGenerateColumns = false;
//
I want this property to be true however if I manually change it in the source it gets changed back to false whenever I edit the GUI. I didn't see this property listed in the properties box for the DataGridView control so I can't figure out how to permanently modify this value. Can anyone let me know where I should be looking?
Thanks in advance.
|
|
|
|
|
The AutoGenerateColumns property gets added when you assign a DataSource to the DataGridView in the Properties Window. It doesn't stop the columns being generated though, at least not on my system when I just tested it.
The MSDN page for the property here[^], has an example showing where and how to set it. (Sets it to false)
If I search for the property in the Index from within the VS IDE, I get a different page with a different example. (Sets it to true)
So take your pick. You really should search MSDN at the very least before asking here, and preferably Google as well. Your question has been hanging about for nearly 24 hours when you could have had the solution almost instantly.
Henry Minute
Do not read medical books! You could die of a misprint. - Mark Twain
Girl: (staring) "Why do you need an icy cucumber?"
“I want to report a fraud. The government is lying to us all.”
|
|
|
|
|
Hi all,
I'm trying to track down why my report takes so long to load the first time but subsequent loads are quite quick. I'm setting the datasource of the report to a dataset, but that's done every time. However, in stepping through the code, I've found that the first time I run this segment of code, it takes a few seconds for the data source to get set. But on subsequent runs it takes no longer than any other command. Any ideas? I've posted the relevant part of the code below.
If ds.Tables(0).Rows.Count > 0 Then
AddImageColumn(ds.Tables(0), "ClientPic")
Dim myFilename As String
myFilename = myG.AppLocation & "\" & myDB.DoExecScalarQuery("select picture from personal")
If File.Exists(myG.AppLocation & "\ClientDocs\" & myG.Patient & "_clientimage.jpg") Then
If File.Exists(myFilename) Then
LoadImage(ds.Tables(0).Rows(0), "ClientPic", myFilename)
End If
ds.WriteXml(applocation & "\personal.xml")
ds.WriteXmlSchema(myG.AppLocation & "\personal.xsd")
'Dim rptPersonal As New crptPersonalInfo ' now declared in main
rptPersonal.SetDataSource(ds) ' THIS IS THE LINE THAT'S SLOW THE FIRST TIME
' Dim rptPersonalViewer As New frmReportViewer ' now declared in main
rptPersonalViewer.cr.ReportSource = rptPersonal
rptPersonalViewer.ShowDialog()
Else
MsgBox("Please check your personal information. It appears some of it may be missing.",
MsgBoxStyle.OkOnly, "No Data For Report")
End If
Catch ex As Exception
Dim myE As New EventLogging.EventLogging
myE.StoreEvent("frmRptParams.RunReport", "Error running report", ex.Message & vbCrLf & vbCrLf & "SQL was: " & strPersonalInfo)
myE = Nothing
MsgBox("There was a problem gathering data for the Personal Info report. If the problem persists please contact customer service.", MsgBoxStyle.Exclamation, "Report Not Run")
Finally
da = Nothing
ds = Nothing
End Try
Denise "Hypermommy" Duggan
|
|
|
|
|
ActiveElement property of Document class of WebBrowser always return BODY Element. if you know why it does send me answer. otherwise please send me a code snippet which it works well.
Thanks
|
|
|
|
|
(using .net 3.5)
I'm trying to get a list of groups that a given user is a member of. I'm trying to use the following code (using the System.DirectoryServices.AccountManagement namespace):
PrincipalContext context = new PrincipalContext(ContextType.Domain, "myDomain");
UserPrincipal userPrincipal = UserPrincipal.FindByIdentity(context, IdentityType.SamAccountName, this.UserID);
PrincipalSearchResult<Principal> groups = userPrincipal.GetGroups(context);
It's throwing an exception on the 2nd line of code, saying that the userID or password is invalid.
I know for a fact that the userID I'm using exists on the domain. What am I doing wrong?
EDIT (SOLUTION) =====================
I had to change the first line to this:
PrincipalContext context = new PrincipalContext(ContextType.Domain, "myDomain", userID, password);
"Why don't you tie a kerosene-soaked rag around your ankles so the ants won't climb up and eat your candy ass..." - Dale Earnhardt, 1997 ----- "...the staggering layers of obscenity in your statement make it a work of art on so many levels." - Jason Jystad, 10/26/2001
|
|
|
|
|
In a .aspx page I have taken a detailsview and in the template field I have taken a btton.
I want the code that if I click on the button the data part of the detailsview will change in a textbox whrer I can change the data and can update it on the database
|
|
|
|
|
|
I've noted with interest that there seems to be a lack of open source tools for .NET test coverage analysis. I'm pretty comfortable with .NET, but off the top of my head, I can't figure out how someone could do it without making their own version of the runtime or tampering with the IL emitted when code is compiled (which sounds like either great resume material, insanity, or possibly both).
I'm just kind of curious, but I'm not sure even how this sort of thing is typically done.
|
|
|
|
|
Easier than tampering with the IL is tampering with the source code. I used to do formal unit testing and I don't know if it's a formal term or not but we called it "instrumenting a file" and it's a bit of tedium that automated processes are made for. The trick is to modify the source without actually changing the control flow of the code. Take the following function:
private void MyMethod()
{
int x = SomeFunction();
int y = SomeOtherFunction();
if (x > y)
{
}
else
{
}
} There are 5 bits of code you need to ensure are executed, so for each place insert a boolean:
static bool flag1 = false;
static bool flag2 = false;
static bool flag3 = false;
static bool flag4 = false;
static bool flag5 = false;
private void MyMethod()
{
flag1 = true;
int x = SomeFunction();
flag2 = true;
int y = SomeOtherFunction();
flag3 = true;
if (x > y)
{
flag4 = true;
}
else
{
flag5 = true;
}
} Then you can run your test cases and check the value of your bools to make sure that all of your code was executed. Note that the control flow of the code hasn't changed, we've just added stuff to verify that all bits are executed. The difficulty comes in when you start taking into account the endless variations of source code. For example:
private void MyMethod()
{
int x = SomeFunction();
int y = SomeOtherFunction();
if (x > y)
{
}
} looks easier, but you still need to insert the else to the if when you instrument that method to prove that the if statement can be failed. If the if can't be failed then it's unnecessary (dead code) and shouldn't be there.
The biggest PITA to instrument (and test) is full MCDC coverage (google it). Take the following sample:
private void MyMethod(bool a, bool b)
{
if (a || b)
{
}
} There's a multi-conditional if statement there, and you need to prove that both conditions are necessary. Why? Well, suppose hypothetically that a is always true . Then the statement will always evaluate to true and there's no point in checking either a or b . The same thing happens if b is always true, so you need to instrument that in such a way to prove that both a and b can be false independently of each other. To verify full coverage that one statement turns into something like this:
static bool flag1 = false;
static bool flag2 = false;
static bool flag3 = false;
static bool flag4 = false;
private void MyMethod(bool a, bool b)
{
flag1 = true;
if (a && !b)
{
flag2 = true;
}
else
{
if (b)
{
flag3 = true;
}
else
{
flag4 = true;
}
}
} and that 's just a simple multi-conditioned statement! Try figuring out how to break this down:
if (a || ((b && c) || d) || (x > 2))
{
} Hopefully you either don't care about such things or you can afford to buy a tool to do this for you. Trust me, it will drive you crazy.
|
|
|
|
|
The .NET Framework has a profiling API available for just such a thing. Here's a nice introductory article.[^].
"we must lose precision to make significant statements about complex systems."
-deKorvin on uncertainty
|
|
|
|
|
The CLR profiler allows you to rewrite IL at JIT time. That would be one place to put instrumentation code to track what code is getting executed.
|
|
|
|
|
I have a set of objects that I want to do some processing on prior to serializing and after deserializing,using wcf for coms.
The code is included below. I understand that I should change OnDeserializing to OnDeserialized, and have, but neither get called.
If I put a break in the OnSerializing method, the debugger stops there. If I put a break in the OnDeserializing method, the debugger never stops there. It is also clear from the errors I am getting that the re-hydration has not happened.
I am following the same pattern for both the pre and post calls. The compiler is happy with them, and they look like they match the patterns in the online doc.
Any ideas? This is also posted on MSDN with no help forthcoming.
hury Plz snd code and dollars
TIA
[OnSerializing ()]
internal void OnSerializingMethod(StreamingContext context)
{
long temp = 0;
if (context.State != StreamingContextStates .Clone)
{
Dehydrate (null , ref temp);
}
}
[OnDeserializing ()]
internal void OnDeserializingMethod(StreamingContext context)
{
if (context.State != StreamingContextStates .Clone)
{
Rehydrate (0);
}
}
Silver member by constant and unflinching longevity.
|
|
|
|