|
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.
|
|
|
|
|
livez wrote: Could you give a pointer of how you would solve my problem with datetime-class?
Create a DateTime object with the relevant date, add or subtract one day until it's the first day of the week (i.e Sunday or Monday), save that date. Add one day until it's the last day of the week, save that date. Look at the DateTime members to see what is possible.
|
|
|
|
|
"Create a DateTime object with the relevant date" But its the relevant date I dont have. I have a year and a weeknr. How do I create a relevant datetime-object with that?
|
|
|
|
|
Create a DateTime(year, 1, 1)
Adjust by day until the day is Thursday to get it to week 1
Add 7 x week number
Adjust day back and forward to find Monday and Sunday
|
|
|
|
|
|
got it working with your suggestion (with a slight adjustment), thanks!
|
|
|
|
|
Try this -
CultureInfo info = Thread.CurrentThread.CurrentCulture;
DateTime dt = info.Calendar.AddWeeks(new DateTime(YYYY, MM, DD), x); where x is no of weeks.
The interesting thing to note here is that if you use the first day of the first week of the previous year (i.e. 2008/12/28) evertything works fine. If you use new DateTime(2009, 1, 1),you would get that date plus 53 weeks which would not help you as per your query. Hope that makes sense .
|
|
|
|
|
DateTime does not appear to handle week of year at all - much to my suprise. Fortunately, I had to implement this for a real-time project many years ago. For the full rules, look for ISO-8601 which is the standard reference for dates and times, but:
1) Week number is 1 - 53.
2) Weeks start on Monday.
3) Week one is always the week with the first Thursday of the new year. I.e., if January the 1st is a Monday, Tuesday, Wednesday or Thursday, it is in week 1. Otherwise it is in the final week of the previous year (which could be week 51, 52, or 53 dependant on when week 1 was in that year).
Yes, this means that December 29th, 30th and 31st could be in Week 1 of the new year!
All those who believe in psycho kinesis, raise my hand.
|
|
|
|
|
This might help:
http://en.wikipedia.org/wiki/ISO_week_date[^]
It tells you how to calculate the week number for any given date, so it shouldn't be too hard to "reverse engineer" it to come up with the date corresponding to a given week number.
|
|
|
|
|
Thanks, Ill check it out!
|
|
|
|
|
I already got my code to work.
|
|
|
|
|
Richard MacCutchan wrote: I already got my code to work.
Teacher's pet!
|
|
|
|
|
Yeah and I brought an apple today.
|
|
|
|