i have facing a problem. A datetimepicker on my windows form and i set the format properties to Custom and CustomeFormat to dd/MM/yyyy but when i run the application the datetimepicker display the calendar MM/dd/yyyy. I want consistent format in my application that is dd/MM/yyyy . Below is the picture for better understanding.
and Runtime datetimepicker displaying like below screen
Code that is generating in designer
this.engageDateDateTimePicker.CustomFormat = "dd/MM/yyyy";
this.engageDateDateTimePicker.DataBindings.Add(new System.Windows.Forms.Binding("Value", this.prol01BindingSource, "EngageDate", true, System.Windows.Forms.DataSourceUpdateMode.OnValidation, null, "d"));
this.engageDateDateTimePicker.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
this.engageDateDateTimePicker.Format = System.Windows.Forms.DateTimePickerFormat.Custom;
this.engageDateDateTimePicker.Location = new System.Drawing.Point(885, 96);
this.engageDateDateTimePicker.Name = "engageDateDateTimePicker";
this.engageDateDateTimePicker.Size = new System.Drawing.Size(136, 20);
this.engageDateDateTimePicker.TabIndex = 27;
this.engageDateDateTimePicker.ValueChanged += new System.EventHandler(this.engageDateDateTimePicker_ValueChanged);
Can you tell me how can i resolve this
I suspect you haven't set the Format property appropriately on the picker. From the docs for DateTimePicker.CustomFormat:
The Format property must be set to DateTimePickerFormat.Custom for this property to affect the formatting of the displayed date and time.
Related
I tried two PickerComponents inside a TextModeLayout with the simulator (with an Android skin). I don't like that a PickerComponent of Strings shows three dots on unselected state. I also don't like that the PickerComponent of a Date shows the today date. In both cases, I want to show a custom text, also because I don't want a default selected value. For example, if I want to pick the date of birth, I don't feel that it makes sense to preset the today date.
After a lot of trials, I tried to solve this issue with the following code, but I'm not sure if it's a correct way. My question is what is the best approch in a portable manner (that is ok for Android and for iOS):
/**
* Set a custom text for an unselected PickerComponent placed in a
* TextModeLayout
*
* #param picker
* #param text
*/
private void pickerComponentSetUnselectedText(PickerComponent picker, String text) {
picker.getPicker().setText(text);
picker.getPicker().setUIID("TextHint");
picker.getPicker().addActionListener(l -> {
l.getComponent().setUIID("TextField");
});
}
I tried to use that method so:
TextModeLayout textModeLayout = new TextModeLayout(4, 1);
Container inputPersonData = new Container(textModeLayout);
TextComponent name = new TextComponent().label("Nome");
TextComponent surname = new TextComponent().label("Cognome");
PickerComponent gender = PickerComponent.createStrings("Maschio", "Femmina", "altro").label("Genere");
PickerComponent date = PickerComponent.createDate(new Date()).label("Data di nascita");
inputPersonData.add(name);
inputPersonData.add(surname);
inputPersonData.add(gender);
inputPersonData.add(date);
pickerComponentSetUnselectedText(gender, "Genere");
pickerComponentSetUnselectedText(date, "Data di nascita");
The picker component has two pieces, the one with the text isn't native but the popup is (and that's the source of most of the problems).
If what you did worked go with it. Historically we would recommend subclassing picker and overriding updateValue but it's impossible to do with PickerComponent so I added a new method which should be available in the next update:
PickerComponent cmp = new PickerComponent() {
protected Picker createPickerInstance() {
return new Picker() {
protected void updateValue() {
// place your logic here.. and invoke setText(...);
}
};
}
};
I have a custom profile field "field_date_observed" which has format "2014-10-21". I am trying to set its value using the code further down but am getting the error:
EntityMetadataWrapperException: Invalid data value given. Be sure it matches the required data type and format. in EntityMetadataWrapper->set()
The code:
$todays_date = date('Y-m-d');
$uid=23;
$obj_container = user_load($uid);
$obj = entity_metadata_wrapper('user', $obj_container);
$obj->field_date_observed = $todays_date;
$obj->save();
You need to use UNIX timestamp format to set the date value with entity_medata_wrapper.
Try changing the first line to:
$todays_date = strtotime(date('Y-m-d'));
I have a combo box that has a status in it and when it is changed from Open to Closed, transferred or Pending I would like to populate two text boxes with the current date and time. I have an after update module created that looks at the value of the combo box and then updates the text of the text box to the current date and time but it is not working.
It either doesn't do anything or I get an error about setting the focus. I appreciate any help.
If Me.CmbStatus.Value = "Closed" Then
Me.Date_Completed.Text = Date
Me.Time_Completed.Text = Time
ElseIf Me.CmbStatus.Value = "Pending" Then
Me.Date_Completed.Text = Date
Me.Time_Completed.Text = Time
ElseIf Me.CmbStatus.Value = "Transferred" Then
Me.Date_Completed.Text = Date
Me.Time_Completed.Text = Time
I am developing an windows application in F#. In the application I have to show the TextBox mode in Password Format. What is the code for using the password mode of TextBox in F#?
I have applied the following code:
let txtpwd = new TextBox(Top = 70, Left = 120)
From the above code the textbox is displaying. No problem. I have applied following code for password mode:
txtpwd.PasswordChar
The above code is not working properly.
You should set desired properties upon initialization of your control, for example:
txtpwd.Text <- "" // Set to no text
txtpwd.PasswordChar <-'*' // The password character is an asterisk
txtpwd.MaxLength <- 14 // The control will allow no more than 14 characters
Better yet, set the properties in your call to the constructor. One of the cool things about F# is that you can set properties in the call that you wouldn't normally be able to set in the constructor. Like this:
let txtpwd = new TextBox(Top = 70, Left = 120, Text = "", PasswordChar = '*',MaxLength = 14, Multiline = true)
This is basically equivalent to what Gene posted but, as far as I know, it's a little more idiomatic in F#.
If you check this page under the topic "Assigning Values To Properties At Initialization" (sorry can't post a direct link) although the page is discussing F# code, it holds for other .Net code as well.
I want to show the color and font dialog box in WPF .net 4.5, how to can I do?
Please help me anybody.
Thnx in Advanced!
The best out of the box solution is using FontDialog form System.Windows.Forms assembly, but you will have to convert it's output to apply it to WPF elements.
FontDialog fd = new FontDialog();
var result = fd.ShowDialog();
if (result == System.Windows.Forms.DialogResult.OK)
{
Debug.WriteLine(fd.Font);
tbFonttest.FontFamily = new FontFamily(fd.Font.Name);
tbFonttest.FontSize = fd.Font.Size * 96.0 / 72.0;
tbFonttest.FontWeight = fd.Font.Bold ? FontWeights.Bold : FontWeights.Regular;
tbFonttest.FontStyle = fd.Font.Italic ? FontStyles.Italic : FontStyles.Normal;
TextDecorationCollection tdc = new TextDecorationCollection();
if (fd.Font.Underline) tdc.Add(TextDecorations.Underline);
if (fd.Font.Strikeout) tdc.Add(TextDecorations.Strikethrough);
tbFonttest.TextDecorations = tdc;
}
Notice that winforms dialog does not support many of WPF font properties like extra bold fonts.
Color dialog is much easier:
ColorDialog cd = new ColorDialog();
var result = cd.ShowDialog();
if (result == System.Windows.Forms.DialogResult.OK)
{
tbFonttest.Foreground = new SolidColorBrush(Color.FromArgb(cd.Color.A, cd.Color.R, cd.Color.G, cd.Color.B));
}
It does not support alpha though.
You can use classes from System.Windows.Forms, there is nothing wrong with using them. You'll probably need to convert values to WPF-specific though.
Alternatively, you can implement your own dialogs or use third-party controls, see Free font and color chooser for WPF?.