|
I was pretty much sure that as DataGridViewColumn implements IComponent, it should throw exception when manipulated by another thread. I am little bit surprised to see that we can change any property of DataGridViewClumn from any thread while it is not possible for DataGridView itself.
How is it possible that DataGridView is not editable from another thread while the datagridviewcolumn is?
I am waiting for the answer since 24 hours..
Jayant D. Kulkarni
modified on Thursday, December 10, 2009 11:29 PM
|
|
|
|
|
On creation of multifile assembly,
When i run the csc command, it gives error stating that csc command is not valid.
Can anyone say how to compile the files to create multifile assembly.
Thanks & regards,
sandhiya
|
|
|
|
|
Determine the full path of CSC and either use it or add it to the PATH environment variable.
|
|
|
|
|
I am trying to understand the standard class HashSet<T>. As I understand it, this class implements a hash table. For example, it supports the method Add which adds members to the hash table. It also supports a method Contains which returns a boolean value whether or not the data item is in the table. Let say, I am writing an application with the following class:
class person {
public int id;
public string name;
}
Now, I am going to need to overload the operators == and != for the class person. My comparison
operator will return equal if and only if the classes have the same id. If I do that,
then I believe that I can write the following declaration:
HashSet<person> personSet;
Now, given the declaration of personSet, I know how to add things to it, but given an id, how do I find the person's name. That is, I would expect that the class should have some kind of find method. However, after looking thought the documentation, I failed to find such a function. I did find a method Contains, but that just returns a bool value. What am I missing?
Thanks
Bob
|
|
|
|
|
One possible way is to enumerate the personSet and check for each person id with the expected id. Or use the extension methods like First , FirstOrDefault etc. Doing all these breaks the advantage HashSet offers and lead to O(n) complexity.
HashSet can be used only when you need to remember a value that you have already seen and when you don't care about other details about the value. Consider a scenario where you need to remove duplicates from a list. You iterate the list and add each elements to a HashSet checking Contains() before each insert. All these searches takes constant time and this makes huge difference when working with big collections.
Having said that, I think HashSet is not the right class you need. You need an associative container. Take a look at Dictionary<TKey, TValue> . Create a dictionary like Dictionary<int, Person> . Now the ids are associated with each person objects. Given an id, you can easily find the person object with a constant (O(1)) complexity.
BobInNJ wrote: I am going to need to overload the operators == and != for the class person. My comparison
operator will return equal if and only if the classes have the same id
A recommended practice is to override Equals() and let your operator overloads call this equals. You may also need to override GetHashCode() .
Best wishes,
Navaneeth
|
|
|
|
|
Hello. I have tried much here.
I want this words so be deleted everytime they are seen.
MBR
MBA
MSc Economics
I have tried this:
richTextBox1.Text = richTextBox1.Text.Replace("MBR","");
richTextBox1.Text = richTextBox1.Text.Replace("MBA","");
richTextBox1.Text = richTextBox1.Text.Replace("MSc Economics", "");
But there are comming a whitespace, and I don't want a blank space.
I want it to be total deleted.
If we have a name called: Jensen, MBA, Johan
Shall MBa be deleted so there only will be this back: Jensen Johan
With only one blank space..
Plx help
|
|
|
|
|
From you example:
You have
Jensen, MBA, Johan
You want
Jensen Johan
I consider in my answer that you want to remove (MBR/MBA/MSc Economics + all between comas)
You need to use regular expression rather than a simple Text replace.
String test = "Jensen, MBA, Johan";
String result = Regex.Replace(test, @",\s*(MBR|MBA|MSc Economics)\s*,", "");
In order to get Regex add:
using System.Text.RegularExpressions;
|
|
|
|
|
Another approach, locate for the first "," and second ','. Then remove that part of the string from the main string.
Something like -
temp.Remove(temp.IndexOf(","),temp.LastIndexOf(",") - temp.IndexOf(","));
|
|
|
|
|
Thanks for replies.
What if i have over 100 names in one Richbox, how could i so do it? :9
|
|
|
|
|
Hello,
I have a SmartDevice project (.NetCF 2.0) configured to be tested on the USA Windows Mobile 5.0 Pocket PC R2 Emulator. My project uses SqlCe 3.0. Understanding that a SmartDevice project is "more carefull" with the device's memory I am using SqlCeResultSets. The result sets are strongly typed, autogenerated by Visual Studio 2008 using the custom tool MSResultSetGenerator.
The problem I am facing is that the result set does not recognize any column names. The autogenerated code for the fields does not work.
In the client code I am using
InfoResultSet rs = new InfoResultSet();
rs.Open();
rs.ReadFirst();
string myFormattedDate = rs.MyDateColumn.ToString("dd/MM/yyyy");
When the execution on the emulator reaches the rs.MyDateColumn the application throws an System.IndexOutOfRangeException .
Investigating the stack trace
at System.Data.SqlServerCe.FieldNameLookup.GetOrdinal()
at System.Data.SqlServerCe.SqlCeDataReader.GetOrdinal()
I've tested the GetOrdinal method (in my autogenerated class that inherits SqlCeResultSet):
this.GetOrdinal("MyDateColumn");
this.GetName(1);
this.GetOrdinal(this.GetName(1));
Am I doing something wrong or am I missing something?
Thank you.
I have no smart signature yet...
modified on Wednesday, December 9, 2009 12:33 PM
|
|
|
|
|
If I have understood your issue:
if (! yourReader.IsDBNull(yourReader.GetOrdinal("MyDateColumn")))
myTime = yourReader.GetDateTime(yourReader.GetOrdinal("MyDateColumn"));
else
myTime = DateTime.MinValue;
This is because DateTime used internaly cannot handle null value
|
|
|
|
|
Thanks for your answer, but that is not the issue. The code does not fail at reading the data. The code fails at myReader.GetOrdinal("MyDateColumn")
If I use myReader.GetDateTime(1); the code works, but is dependent of the position of the column in the schema.
If I use myReader.GetDateTime(myReader.GetOrdinal("MyDateColumn")); the code does not work...
If I use myReader.GetOrdinal("MyDateColumn") the code does not work...
If I use myReader.GetName(1) the code works and the return value from the function is "MyDateColumn"...
I've worked before with ADO.Net and never had this issue. Now I am using SqlCe (SqlCeResultSet) and the only thing I can think about is that SqlCe is responsible for this (or the managed wrapper).
Any other ideeas?
I have no smart signature yet...
|
|
|
|
|
Hello,
another (I hope) little problem. I have written an own TabPage (derrived from TabPage), that is correctly initialized. Later, when the User clicks a button, the information should be updated. The button Event ist handeld correctly and the programm tries to set e.g. a new text into a Label. But the new text is never displayed. I have tried the methods "Refresh" and "Update" on both TabPage AND Label, but nothing changes. What I am doiing wrong?
Grretings, Taggi
How do you know, that Tagamoga has been assimilated by the borg?
"Recistunce ist fiutille."
Sorry for violating the english language.
|
|
|
|
|
Hard to say without seeing the code you are using. Could you post the relevant code snippets please.
|
|
|
|
|
Hello.
I will try hard.
Well, when my own written Tab is in Focus a special Button occurs. Clicking on it, it evokes following function:
private void monatsUebersichtNeueAuswertung_Click(object sender, EventArgs e)
{
MonatsUebersichtDialog dlg = new MonatsUebersichtDialog();
if (dlg.ShowDialog() == DialogResult.OK)
{
MonatsUebersichtTab tab = (MonatsUebersichtTab)Reiteransicht.SelectedTab;
tab.setNewData(dlg.User, dlg.Von, dlg.Bis, dlg.Projekt);
tab.Update();
tab.Refresh();
dlg.Dispose();
}
}
The function "setNewData" should now update the page with the new information.
public void setNewData(String newUser, String newVon, String newBis, String newProjekt)
{
lblName.Text = myData.ToString();
lblName.Update();
lblName.Refresh();
this.Update();
this.Refresh();
}
But this Label shows never the new Text. And yes, myData.toString() return the correct String value.
Greetings, Taggi
How do you know, that Tagamoga has been assimilated by the borg?
"Recistunce ist fiutille."
Sorry for violating the english language.
|
|
|
|
|
hmm...
First a couple of observations that won't directly effect the update.
You should have the dlg.Dispose() outside the if statement or it won't be disposed if you cancel.
You shouldn't ever have to call Update or Refresh . Setting the Text property causes the control to repaint anyway.
As to the Label failing to update. Nothing jumps out at me as obviously wrong. However you have subclassed the TabPage itself, and tabpages are often a pain.
Would I be correct in assuming that your Label is in the TabPage ? Or is it in a Panel on the Tabpage ?
One possible issue is that if the Label BackColor is set to Transparent it may cause painting issues when used on a TabPage .
Try using a standard System.Windows.Forms.TabPage and updating the label text from the monatsUebersichtNeueAuswertung_Click method.
Finally, good post. To many posts here have not syntax colouring, no use of code tags, and often no code either. Thanks.
|
|
|
|
|
Hello.
Thank you for your reply!
First about the dlg.Dispose() in the wrong place: Yes you are right. But a question: Isn't it in C# the same like in Java with carbage collector? I know that in c++ you have to take care by your own about your objects. But does c# not have a carbage collector?
Second: My Label is directly in the TabPage and doesn't have got a transparent Background. What are exactly panels for? Only for Layout, isn't it?
Third: I have tried with a standard TabPage and it works there perfect.
It's disgusting.... I cannot be too dump for this "problem".
Sorry, for not posting my code in my first post. I though this is a so basic problem, that I didn't understand, so that no code would be nessacary. And the snytax highlighting was made by your forum...
Well I wish you a good night, I hope a little sleep will perhaps help me.
Greetings, Taggi
How do you know, that Tagamoga has been assimilated by the borg?
"Recistunce ist fiutille."
Sorry for violating the english language.
|
|
|
|
|
You are quite correct, C# does have a garbage collector, however it is best practice to call dispose making the dialogue available for garbage collection explicitly, rather than it hanging around waiting for the .Net framework to decide it needs the memory back.
Interestingly, if you call .ShowDialog() then it is up to you to Dispose of the object. However calling .Show() will automatically invoke .Dispose() for you when the form has closed.
I can't think what could be causing the problem with the Label, however if you could send me the code for your TabPage I can try it out and see if I can work out what is happening. A bit big to post here I guess so Zip and Email it direct (using the Email link below).
|
|
|
|
|
I'm writing a small C# WinForms app. I'm not using ClickOnce (so far as I'm aware). I am making a call to
System.Windows.Forms.Application.UserAppDataPath
from another thread (other than the main UI thread) that was started *after* the main form's Form_Load event handler. This keeps causing InvalidDeploymentException to be thrown, claiming the "Application identity is not set" as an error message. Is there some magic incantation to prevent these from popping up? It's really f'ing annoying at this point.
|
|
|
|
|
I don't know your specific problem. But when working with IIS I have a similar problem using impersonation.
In this case, the initial thread must set some variable (maybe a static variable) with the current WindowsIdentity (I think it is WindowsIdentity.GetCurrent)
And then, every other thread must get that static variable and call .Impersonate() in it.
As I said, I don't know if this is the same problem, but at least give it a try.
|
|
|
|
|
OK, thanks, I'll look into that. Personally that seems idiotic to have to bother with, since at the Win32 level they already had to pass in security credentials (or NULL to use the current default creds) when the thread handle was created. Seems hacky and error prone, but that's the fault of MS, not you.
|
|
|
|
|
Jim Crafton wrote: System.Windows.Forms.Application.UserAppDataPath
from another thread
I believe you need to avoid doing that. Since it is a static property, it will be specific for the current thread. Try to pass the value to worker thread as a parameter when you start it.
Best wishes,
Navaneeth
|
|
|
|
|
Hello!
Im trying to figure out how I get the dates for the first and last day of a given year and week.
For instance:
year: 2009 week:53 = 2009/12/28 - 2010/01/03
year: 2010 week:1 = 2010/01/04 - 2010/01/10
Does anyone know how to achieve this?
|
|
|
|
|
Use the DateTime structure[^] to create an object of the type you require, then adjust the values to get the dates you are looking for.
|
|
|
|
|
Hello and thanks for your reply. I don´t see how it would be that easy though.
Could you give a pointer of how you would solve my problem with datetime-class?
I´ve been trying to use System.Globalization.Calendar with AddWeeks etc, but have yet to make it work.
|
|
|
|
|