|
Can you explain in details please.
suhas bothe
|
|
|
|
|
The 'AfterCheck' event occurs after the tree node check box is checked. Just delegate this event and in the function you'll get 'TreeViewEventArgs' as the second parameter.
It would have all the information you are looking out for.
For more details you can refer to the 'AfterCheck' help in MSDN.
There are two types of fools in this world: One who give advice and the others who do not take it...
|
|
|
|
|
Hi guys, im trying to write a multimonitor application, how do i move a form to the second monitor, well whats the best way? i use the following code i wrote some time ago, not sure its the best way though, i want the least amount of overhead.
using(DXQuartz frm_quartz = new DXQuartz())
{
Screen[] screen = new Screen[1];
screen = Screen.AllScreens;
frm_quartz.Location = new Point(screen[1].WorkingArea.Left, screen[1].WorkingArea.Top);
frm_quartz.Size = new Size(screen[1].WorkingArea.Width, screen[1].WorkingArea.Height);
frm_quartz.Show();
}
Any help on this would be amazing, there is probibly a built in method for this im missing, thanks for the input
si
|
|
|
|
|
Hi!
There are 2 problems with this code:
1. The assignment screen = new Screen[1]; doesn't have any effect because you're assigning Screen.AllScreens to screen in the next line.
2. The code will throw an IndexOutOfBoundsException if there's only one Screen available.
Otherwise it's the normal way to make the form fill the second screen...
Regards,
mav
--
Black holes are the places where God divided by 0...
|
|
|
|
|
Hi,
Why is it that my Convert.ToDateTime isn't working any more...
Usually when i said DateTime Test = Convert.ToDateTime(System.DateTime.Now); the value of Test was "2006/09/11 14:00:00 PM" now it is "11/9/2006" not at all what i want... Is there a setting to change this?
The regional settings are the same as when the Convert.ToDateTime work right...
"Many of life's failures are people who did not realize how close they were to success when they gave up." Thomas A. Edison
|
|
|
|
|
try out
Test.ToString("MM/dd/yyyy");
rahul
|
|
|
|
|
I might be wrong but wouldn't this: Test.ToString("MM/dd/yyyy"); bring back the value "11/09/2006"...
I'm looking for the value of "2006/09/11 14:00:00 PM"
Usually the Convert.ToDateTime brought back this value that i'm looking for without a problem... on my friends PC this Convert.ToDateTime(System.DateTime.Now); brings back the value "2006/09/11 14:00:00 PM" but not on mine... as it brings back the wrong value format..."11/09/2006"
What could the reason be for this?
Thank you in advance...
Regards Nico
"Many of life's failures are people who did not realize how close they were to success when they gave up." Thomas A. Edison
|
|
|
|
|
then try
Test.ToString("yyyy/dd/MM")+" "+Test.ToLongTimeString();
rahul
|
|
|
|
|
I really don't understand what you are trying to do because System.DateTime.Now already returns a DateTime object. So the Convert.ToDateTime() method call is redundant - it does nothing.
NarutoFan#1 wrote: the value of Test was "2006/09/11 14:00:00 PM" now it is "11/9/2006" not at all what i want
No, the value of Test is a DateTime object (which has no culture specific representation)
|
|
|
|
|
I just used the System.DateTime.Now as and example. That could be a string "2006/12/12 14:00:00 PM", The thing is ... usually when i used the Convert.ToDateTime("WHATEVER") the correct value (being "2006/09/11 12:00:00 PM" so the format was "yyyy/MM/dd hh:mm:ss") but now it brings back a value of "11/09/2006" which is "dd/MM/yyyy". How could this be? I change nothing that i know of....
Please help.
"Many of life's failures are people who did not realize how close they were to success when they gave up." Thomas A. Edison
|
|
|
|
|
I suggest that instead of using Convert, use DateTime.Parse.
See Example from MSDN below:
using System;
using System.Globalization;
namespace Parse
{
class Class1
{
public static void Main(string[] args)
{
// Assume the current culture is en-US.
// The date is Feburary 16, 1992, 12 hours, 15 minutes and 12 seconds.
string myDateTimeValue = "2/16/1992 12:15:12";
DateTime myDateTime = DateTime.Parse(myDateTimeValue);
Console.WriteLine("1) myDateTime = {0}", myDateTime);
// Reverse month and day to conform to a different culture.
// The date is Feburary 16, 1992, 12 hours, 15 minutes and 12 seconds.
IFormatProvider culture = new CultureInfo("fr-FR", true);
string myDateTimeFrenchValue = " 16/02/1992 12:15:12";
DateTime myDateTimeFrench =
DateTime.Parse(myDateTimeFrenchValue,
culture,
DateTimeStyles.NoCurrentDateDefault);
Console.WriteLine("2) myDateTimeFrench = {0}", myDateTimeFrench);
// The date is Feburary 16, 1992, 12 hours, 15 minutes and 12 seconds.
string[] expectedFormats = {"G", "g", "f" ,"F"};
myDateTimeFrench =
DateTime.ParseExact(myDateTimeFrenchValue,
expectedFormats,
culture,
DateTimeStyles.AllowWhiteSpaces);
Console.WriteLine("3) myDateTimeFrench = {0}", myDateTimeFrench);
}
}
}
/*
This example yields the following results:
1) myDateTime = 2/16/1992 12:15:12 PM
2) myDateTimeFrench = 2/16/1992 12:15:12 PM
3) myDateTimeFrench = 2/16/1992 12:15:12 PM
*/
if (ToErr == Human.Nature)
{
Forgive = Divine;
}
|
|
|
|
|
Okay thanks,
But why would DateTime TodayTest = DateTime.Now; produce the value "2006/09/11 12:00:00 PM" on my friend's computer but on mine it shows "11/09/2006". What could be the symptoms?
"Many of life's failures are people who did not realize how close they were to success when they gave up." Thomas A. Edison
|
|
|
|
|
NarutoFan#1 wrote: But why would DateTime TodayTest = DateTime.Now; produce the value "2006/09/11 12:00:00 PM" on my friend's computer but on mine it shows "11/09/2006". What could be the symptoms?
DateTime , as I've already said, has no cultural bias. It has no display format. There are a few methods on DateTime that convert it into a culturally biased string. Most of these methods take the culture of the OS (i.e. what is in the control panel for how to display date and time information). The ToString() method on DateTime can be supplied with any format you like if you want to get specific. e.g. DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
|
|
|
|
|
Naruto
You've asked the same question several times. I think you need to provide a little bit more information before we can help you.
Here's a few things to answer/think about:
What type of application is this? Is it WinForms or ASP.NET?
How are you attempting to print out the date? Have you printed out the DateTime.ToLongTimeString() to see if the time is there. BTW - you can't have a value of 14:00:00 PM;)
As I stated in an earlier answer to you, I suspect that your problem is the CurrentCulture. If you are using ASP.NET, then it is entirely possible that the problem is because the culture of the user that ASP.NET runs under is different to yours. To solve this, you can use a "clever" trick to sort this out.
In your Page_Load method, call the following routine:
public static void SetCulture(HttpRequest req)<br />
{<br />
if (req != null && req.UserLanguages != null && req.UserLanguages.Length > 0)<br />
{<br />
SetCulture((string)req.UserLanguages[0]);<br />
}<br />
}<br />
<br />
public static void SetCulture(string culture)<br />
{<br />
CultureInfo ci = new CultureInfo(culture);<br />
Thread.CurrentThread.CurrentCulture = ci;<br />
Thread.CurrentThread.CurrentUICulture = ci;<br />
}
If you call the first method, the user will get data presented to them in the culture that they have set up on their machine. So, somebody from France would probably get information back for the culture fr-FR. Now, calling the second method means that you can specify the culture explicitly, and the user will get information back in that culture, so the same French user would get back information with GB settings if you called SetCulture("en-GB");
Arthur Dent - "That would explain it. All my life I've had this strange feeling that there's something big and sinister going on in the world."
Slartibartfast - "No. That's perfectly normal paranoia. Everybody in the universe gets that."
Deja View - the feeling that you've seen this post before.
|
|
|
|
|
No it's winforms. Thank you...i tried your previous example that you gave me...
CultureInfo culture = new CultureInfo("en-GB");<br />
<br />
DateTime dateTime = Convert.ToDateTime(_appDate+" "+startTime, culture);<br />
DateTime dateTime2 = Convert.ToDateTime(_appDate+" "+endTime, culture);
but this brought back the exact same date "11/09/2006" as when i tried just to
string _fromDateTime = _appDate+" "+startTime;<br />
string _endDateTime = _appDate+" "+endTime;<br />
FromTime = Convert.ToDateTime(_fromDateTime);<br />
ToTime = Convert.ToDateTime(_endDateTime);
but on my friends pc it brings back the value "2006/09/11 02:00:00 PM"
Sorry, in know i'm not explaing enough what my problem is but i'm not even sure what is wrong... its just when i try to compare to dates like in this example: if( _today>=vch.FromDate && _today <=vch.ToDate)
_today has the value of todays date... on my computer it is "11/09/2006" the value of vch.FromDate is "11/09/2006" and the value of vch.ToDate is "11/09/2006"... This if statement should return true... Am i right.
On my computer it returns false... ???? that is just one example... another one was yesterday's problem, but some how that sorted itself out... when the selected time "2006/09/11 02:00:00 PM" was writen into the database the the time would be inserted as AM but without the AM if that makes sense (like so: "2006/09/11 02:00:00.000)... Now it writes the time in the db correctly... "2006/09/11 14:00:00.000" Weird but true...
"Many of life's failures are people who did not realize how close they were to success when they gave up." Thomas A. Edison
|
|
|
|
|
What is vch? Is it a calendar control or something? Could this be the source of your troubles?
Arthur Dent - "That would explain it. All my life I've had this strange feeling that there's something big and sinister going on in the world."
Slartibartfast - "No. That's perfectly normal paranoia. Everybody in the universe gets that."
Deja View - the feeling that you've seen this post before.
|
|
|
|
|
the vch part is a class parameter. it is property in a class.
"Many of life's failures are people who did not realize how close they were to success when they gave up." Thomas A. Edison
|
|
|
|
|
Naruto
Try the following wrapper class and test:
using System;<br />
using System.Collections.Generic;<br />
using System.Text;<br />
<br />
namespace DateWrapper<br />
{<br />
public class WrappedDate<br />
{<br />
private DateTime? _dt = null;<br />
<br />
public WrappedDate()<br />
{<br />
}<br />
<br />
public WrappedDate(DateTime dt)<br />
{<br />
_dt = dt;<br />
}<br />
<br />
public WrappedDate(string dateOnly)<br />
: this(dateOnly, null)<br />
{<br />
}<br />
<br />
public WrappedDate(string date, string time)<br />
{<br />
if (string.IsNullOrEmpty(time))<br />
time = "00:00:00";<br />
if (!time.StartsWith(" "))<br />
time = " " + time;<br />
while (time.IndexOf(" ") > -1)<br />
{<br />
time = time.Replace(" ", " ");<br />
}<br />
try<br />
{<br />
_dt = Convert.ToDateTime(date + time);<br />
}<br />
catch (Exception ex)<br />
{<br />
_dt = null;<br />
}<br />
}<br />
<br />
public DateTime? Date<br />
{<br />
get { return _dt; }<br />
}<br />
<br />
}<br />
<br />
class Program<br />
{<br />
static void Main(string[] args)<br />
{<br />
WrappedDate start = new WrappedDate(DateTime.Now);<br />
WrappedDate dt = new WrappedDate("20/12/2006", "10:00:00");<br />
WrappedDate finish = new WrappedDate(DateTime.Now.AddHours(1));<br />
WrappedDate compare = new WrappedDate(DateTime.Now.AddMinutes(30));<br />
Console.WriteLine(dt.Date.ToString());<br />
<br />
if (compare.Date >= start.Date && compare.Date <= finish.Date)<br />
Console.WriteLine("Success");<br />
else<br />
Console.WriteLine("Failure");<br />
Console.ReadLine();<br />
}<br />
}<br />
}
Arthur Dent - "That would explain it. All my life I've had this strange feeling that there's something big and sinister going on in the world."
Slartibartfast - "No. That's perfectly normal paranoia. Everybody in the universe gets that."
Deja View - the feeling that you've seen this post before.
|
|
|
|
|
Hi Pete, i have great news...
The problem is only on my pc. As soon as i build and install onto another pc it works fine...
The variable shows me the wrong values in the debugger but somehow it contains the correct values and writes these correct values into the database.
The problem still eludes me, but for now it at least works on the client's computers.
Thank you for taking the time to help out...
Regards
Nico
"Many of life's failures are people who did not realize how close they were to success when they gave up." Thomas A. Edison
|
|
|
|
|
That's great news.
I'll have a think about it some more, but it sounds as though the problem might have been with the debugger. As long as the info gets written properly, then that's all right.
Arthur Dent - "That would explain it. All my life I've had this strange feeling that there's something big and sinister going on in the world."
Slartibartfast - "No. That's perfectly normal paranoia. Everybody in the universe gets that."
Deja View - the feeling that you've seen this post before.
|
|
|
|
|
Hello!
I have a panel with 2 buttons and it has to be possible for user, resize and change location (Drag&Drop) of buttons.
Do you have some tipps for me?
|
|
|
|
|
Have a look here:
http://www.codeproject.com/vb/net/RuntimeMovableControls.asp
Mark
|
|
|
|
|
Thank you for your answer.
The idea is nice, and I will take it, if I don't find a "standard" solution for C#..
Is there a standard solution for this problem?
|
|
|
|
|
Hi,
The background:
I have a class "Search" that has a collection in it. This collection is of type "criteria", where "criteria" is an abstract class. The reason being is that i have some concrete classes "IntCriteria", "StringCriteria", "BoolCritera" that i want stored in the collection and they all inherit from "criteria".
To the problem:
I bind "Search" to a property grid, it works fine and i can see/edit all the properties of search, but when i try i add an item to the collection of "criteria" i cant because it does not know what concrete classes to give me as the option to add (see here http://img242.imageshack.us/img242/5803/exampleko9.jpg to see what i want, this is to add columns to a data grid view). Is there a way i can tag "IntCriteria", "StringCriteria" and "BoolCritera" so that the property grid sees them as a type of "criteria".
if not then, is there anyway i can list "IntCriteria", "StringCriteria" or"BoolCritera" in the add new item screen.
Hope that made sense!!!
To Recreate the problem, make a windows application, create this file (i have put multiple classes in one file for ease)(its only example code, not my actual code!)
<br />
using System;<br />
<br />
using System.Collections.Generic;<br />
<br />
using System.Text;<br />
<br />
using System.Collections;<br />
<br />
namespace TestApp<br />
<br />
{<br />
<br />
public class Search<br />
<br />
{<br />
<br />
private string _A;<br />
<br />
private string _B;<br />
<br />
private CriteriaCollection _cc = new CriteriaCollection();<br />
<br />
public string A<br />
<br />
{<br />
<br />
get { return _A; }<br />
<br />
set { _A = value; }<br />
<br />
}<br />
<br />
public string B<br />
<br />
{<br />
<br />
get { return _B; }<br />
<br />
set { _B = value; }<br />
<br />
}<br />
<br />
public CriteriaCollection cc<br />
<br />
{<br />
<br />
get { return _cc; }<br />
<br />
set { _cc = value; }<br />
<br />
}<br />
<br />
public Search()<br />
<br />
{<br />
<br />
}<br />
<br />
}<br />
<br />
public class CriteriaCollection : CollectionBase<br />
<br />
{<br />
<br />
public CriteriaCollection()<br />
<br />
{<br />
<br />
}<br />
<br />
public void Add(Criteria C)<br />
<br />
{<br />
<br />
this.InnerList.Add(C);<br />
<br />
}<br />
<br />
public void Remove(Criteria element)<br />
<br />
{<br />
<br />
InnerList.Remove(element);<br />
<br />
}<br />
<br />
public Criteria this[int index]<br />
<br />
{<br />
<br />
get { return (Criteria)InnerList[index]; }<br />
<br />
}<br />
<br />
public void CopyTo(Criteria[] target, int index)<br />
<br />
{<br />
<br />
InnerList.CopyTo(target, index);<br />
<br />
}<br />
<br />
public int IndexOf(Criteria element)<br />
<br />
{<br />
<br />
return InnerList.IndexOf(element);<br />
<br />
}<br />
<br />
public bool Contains(Criteria element)<br />
<br />
{<br />
<br />
return InnerList.Contains(element);<br />
<br />
}<br />
<br />
public void Insert(int index, Criteria element)<br />
<br />
{<br />
<br />
InnerList.Insert(index, element);<br />
<br />
}<br />
<br />
}<br />
<br />
<br />
<br />
public abstract class Criteria<br />
<br />
{<br />
<br />
private string _C;<br />
<br />
private string _D;<br />
<br />
<br />
public string C<br />
<br />
{<br />
<br />
get<br />
<br />
{<br />
<br />
return _C;<br />
<br />
}<br />
<br />
set<br />
<br />
{<br />
<br />
_C = value;<br />
<br />
}<br />
<br />
}<br />
<br />
public string D<br />
<br />
{<br />
<br />
get<br />
<br />
{<br />
<br />
return _D;<br />
<br />
}<br />
<br />
set<br />
<br />
{<br />
<br />
_D = value;<br />
<br />
}<br />
<br />
}<br />
<br />
}<br />
<br />
<br />
public class IntCriteria : Criteria<br />
<br />
{<br />
<br />
public IntCriteria()<br />
<br />
{<br />
<br />
<br />
}<br />
<br />
public int DoSomeIntStuff()<br />
<br />
{<br />
<br />
return 0;<br />
<br />
}<br />
<br />
}<br />
<br />
<br />
<br />
<br />
public class StringCriteria : Criteria<br />
<br />
{<br />
<br />
public StringCriteria()<br />
<br />
{<br />
<br />
}<br />
<br />
public string DoSomeStringStuff()<br />
<br />
{<br />
<br />
return "Stuff done";<br />
<br />
}<br />
<br />
}<br />
<br />
<br />
public class BoolCriteria : Criteria<br />
<br />
{<br />
<br />
<br />
public BoolCriteria()<br />
<br />
{<br />
<br />
}<br />
<br />
public bool DoSomeBooleanStuff()<br />
<br />
{<br />
<br />
return true;<br />
<br />
}<br />
<br />
}<br />
<br />
}<br />
<br />
Then on a form add a property grid and add
<br />
private void Form1_Load(object sender, EventArgs e)<br />
<br />
{<br />
<br />
Search s = new Search();<br />
<br />
this.propertyGrid1.SelectedObject = s;<br />
<br />
}<br />
<br />
Run the form and try and add and item to cc in the property grid
TIA
Mark
|
|
|
|
|
Hi,
first create a class inheriting from CollectionEditor and override CreateNewItemTypes. The result should be an array of types which should be choosable.
Then add this attribute to your collection class:
[Editor(typeof(CriteriaCollectionEditor), typeof(System.Drawing.Design.UITypeEditor))]
public class CriteriaCollection : CollectionBase {
}
If you are lucky that's all you need to do .
Robert
|
|
|
|