|
Hello all,
I have read all about changing time from regular time (1:00 PM) to military time (13:00) however I cannot find anywhere about how to let a user enter either of these as valid times. I have an internal app where some users want to enter military time and some want to enter regular time. Right now I only allow the entry of regular time. I would also like to allow military time to be entered with the application "breaking".
Can anyone please assist me?
Thanks a bunch!
~Candi
|
|
|
|
|
stormcandi wrote: Can anyone please assist me?
Probably, but your odds increase greatly if you ask a specific question.
|
|
|
|
|
How can I allow the entry of military and regular time in code?
~Candi
|
|
|
|
|
Oh well then maybe this [^]will help
Last modified: 45mins after originally posted -- fixing URL
|
|
|
|
|
Mike, you used the same link as on the previous question.
All the best,
Martin
|
|
|
|
|
Wow thanks for the quality control message I think it's fixed now.
|
|
|
|
|
How are you getting the data from the user? How are you converting it into a date/time? If you are getting text, I would check it against a regex to see what format it is, or you can use TryParse to see if one fails to be coerced into a date/time. The easiest way to get a helpful answer would be to post your current code that is reading in only "regular" time, so we can make suggestions as to how to modify it to accept military time.
Jeff
|
|
|
|
|
Jeff,
Funny thing is I just double-checked my code and it will accept military time with the : but not without it. So I can just do some checking to make sure the : is in the time and then I am done. (I was trying it without the : to see if it worked.)
~Candi
|
|
|
|
|
Hi,
I am a newbie in C# and I was asked to develop a Windows Control Library. I have understood how to generate one and link it into a Windows Application Test Application. I want to make a property that shows up in the Property window and allows the user to have a pulldown to select the property, does anyone have a tutorial or some sample code to how this is done. I cant find anything online.
Any help would be greatly appreciated
Thanks
|
|
|
|
|
godspeed123 wrote: to have a pulldown to select the property
Depends. If it's just an enum you can just expose a public property of that type and the PropertyGrid will display a combobox. Otherwise you need a type converter.
godspeed123 wrote: anyone have a tutorial
They hide those in the documentation[^]
|
|
|
|
|
I actually have to read the DAQ Board and retrieve its properties and then want to allow the user to select from it.
So for 1 property I will check the computer for the number of DAQ Boards and allow the user to select the DAQ Board of interest with the serial number. Do I have to use this type converter.
Any example?
|
|
|
|
|
godspeed123 wrote: Any example?
yes, the link in my previous post
|
|
|
|
|
Thanks for the help, I have linked it all up and it works!!
One more question is if I have an array with serial numbers in the Windows Control Library class, how do I send it over to the StringConverter class.
So in:
<br />
public class UserControl1 : System.Windows.Forms.UserControl<br />
{<br />
...<br />
<br />
public string daqSerial = new string[10];<br />
private string testProperty;<br />
<br />
...<br />
<br />
public void RetrieveSerials() {<br />
... <br />
}<br />
<br />
[DescriptionAttribute("Serial"),<br />
CategoryAttribute("Global Settings"),<br />
TypeConverter(typeof(testingPropertyConverter))]<br />
public string TestProp <br />
{<br />
get <br />
{<br />
return testProperty;<br />
}<br />
set <br />
{<br />
testProperty = value;<br />
}<br />
}<br />
}<br />
<br />
public class testingPropertyConverter : StringConverter <br />
{<br />
public override bool GetStandardValuesSupported( ITypeDescriptorContext context ) <br />
{<br />
return true;<br />
}<br />
<br />
public override StandardValuesCollection<br />
GetStandardValues( ITypeDescriptorContext context ) <br />
{<br />
return new StandardValuesCollection(new string[]{"test0", "test1", "test2"});<br />
}<br />
}<br />
So instead of putting those fixed values how do I show the daqSerial Array.
Any help would be greatly appreciated
|
|
|
|
|
Hi,
most of the TypeConverter methods receive a context in argument. You can use the Instance property in this context to retrieve your target instance and request from it some informations like your array.
|
|
|
|
|
Thanks for the response, so how does this work?
The function that I am using has the following prototype
<br />
public override StandardValuesCollection<br />
GetStandardValues( ITypeDescriptorContext context ) <br />
{<br />
<br />
return new StandardValuesCollection( ((UserControl1) context.Instance).daq );<br />
}<br />
This code crashes, so I am clearly doing it wrong.
Whats the correct method. Thanks for all the help
|
|
|
|
|
Your code seems correct (but I don't see it in its whole), so I can't say where your error is...
|
|
|
|
|
the error I get is as follows:
The following exception has occurred:
InvalidCastException: Specified cast is not valid.
Does that help? If not I can put up all the code
|
|
|
|
|
So it means the target instance is not from the type you think it is. In debug mode you could confirm. If you are lost, you could send me a small sample (complete solution, no binaries in the zip file please) to reproduce your issue and I will quickly check. Please use my helpdesk at http://www.visualhint.com/index.php/support/submitrequest/
|
|
|
|
|
Hi,
I retrieved my Outlook Contacts list in a checkedlistbox with only the name and the phone numbers, Now I want to be able to get the phone numbers from the checked contacts from the checkedlistbox to be used somewhere else.
string contName = "";
if (oCt.FullName != null)
{
contName = oCt.FullName;
}
if (chckListBox != null)
{
chckListBox.Items.Add(contName + ", " + PhNum);
}
for(int i=1; i
|
|
|
|
|
I have never worked with the CheckedListBox. Therefore if I needed to solve this problem I would consult the documentation.
|
|
|
|
|
Hello,
I never believe LedMike talking about this "documentaion" stuff.
So I checked it, and have to admit that he is write this time.
There[^] is really a fancy little example which just have to be changed a little to fit your needs.
Have fun reading!
All the best,
Martin
|
|
|
|
|
Thanks
do you know how can set all the items to checked state.
private void btnChckAllOLlist_Click(object sender, EventArgs e)
{
chckListBox.SetItemCheckState = ...
}
I Want to be able to checkall with one button.
Thanks
|
|
|
|
|
Hi,
Trying to convert a string to a hex representation, like so
<br />
string str = "greg";<br />
string hex = "";<br />
foreach(char c in str) {<br />
int tmp = c;<br />
hex += String.Format("{0:X2}", (uint)System.Convert.ToUInt32(tmp.ToString()));<br />
}<br />
which works fine for most characters but when I try feeding in the copyright symbol © (not the html entity © ) I get the hex value A9
Doing the same in PHP I get the value C2A9.
do I need to do something to tell String.Format that the current char is a symbol or something else?
Thanks
Greg
-- modified at 13:26 Tuesday 16th October, 2007
|
|
|
|
|
|
UTF8Encoding ue = new UTF8Encoding();
ASCIIEncoding ae = new ASCIIEncoding();
byte[] bytes = ue.GetBytes("©greg");
foreach (byte b in bytes) {
sb.AppendFormat("{0:X2}", b);
}
bytes = ae.GetBytes("©greg");
sb.Length = 0;
foreach (byte b in bytes) {
sb.AppendFormat("{0:X2}", b);
}
Need a C# Consultant? I'm available.
Happiness in intelligent people is the rarest thing I know. -- Ernest Hemingway
|
|
|
|