Maybe this is to simple. If I have a textbox where I want to input a numeric value like "1300" and make it to display like datetime like this "13:00".
So what you should see is only 13:00 but it's also the days date.
anyone understand my question?
May be you need to use Day or Time Picker. This is most common way for Windows Phone to display date and time.
Check also Making a DateTimePicker
and Windows Phone 7 - DatePicker and TimePicker
But if you want to use only TextBox, you need to handled TextBox.LostFocus=OnLostFocus
private void OnLostFocus(object sender, RoutedEventArgs e)
{
//here change text of TextBox however you want.
}
UPD
If you want to place current time to TextBox as default value you can to use
tb.Text = DateTime.Now.ToShortTimeString();
when you arrive to current page or when TextBox.GotFocus=OnGotFocus
private void OnGotFocus(object sender, RoutedEventArgs e)
{
tb.Text = DateTime.Now.ToShortTimeString();
}
UPD2
When in TextBox you have value (for example 1300) you need to parse it and get newHours hours and newMinutes minutes. Then
var today = DateTime.Now;
var newDate = new DateTime(today.Year, today.Month, today.Day, newHours, newMinutes, 0);
Related
I want to display data. I used AfterFieldChange method to display the data but it turns out the radio button doesn't change. I already insert the data customer table, the BAQ (Business Activity Query) also work just that the screen form doesn't work.
private void UD24_AfterFieldChange(object sender, DataColumnChangeEventArgs args)
{
// ** Argument Properties and Uses **
// args.Row["FieldName"]
// args.Column, args.ProposedValue, args.Row
// Add Event Handler Code
//EpiDataView edvUD24 = ((EpiDataView)(this.oTrans.EpiDataViews["UD24"]));
//System.Data.DataRow edvUD24Row = edvUD24.CurrentDataRow;
EpiDataView view = oTrans.EpiDataViews["UD24"] as EpiDataView;
switch (args.Column.ColumnName)
{
case "Character03":
DataTable tblcust=customer(args.Row["Character03"].ToString());
if(tblcust!=null && tblcust.Rows.Count>0)
{
string client = tblcust.Rows[0]["Customer_client1_c"].ToString();
view.dataView[view.Row]["ShortChar04"] = client;
//MessageBox.Show(Client);
}
break;
}
}
After changing the data in the EpiDataView you need to call Notify to make it call the UI elements that need to be updated:
view.dataView[view.Row]["ShortChar04"] = client;
view.Notify(new Ice.Lib.Framework.EpiNotifyArgs(this, view.Row, NotifyType.Initialize));
Kieym, perhaps try adding EpiNotifyArgs into your declaration, like so:
private void UD24_AfterFieldChange(object sender, DataColumnChangeEventArgs args, EpiNotifyArgs args)
I'm using WatIn to create an automated test for a Web App that uses Telerik controls: my first challenge is to drive a Telerik date control - a RadDatePicker.
Simply entering the text in the likeliest input field doesn't work: the value is reset to blank as the form is posted. So I imagine I need a more complex set of automated interactions -- for example, I found this thread on the Telerik site discussing how to automated a selection from a Telerik combo box.
Can anyone supply the magic combination of interactions I need?
(I'm sure that the answer would help anyone using any automated test tool, hence I've also flagged this question with a couple of other test frameworks too :-))
I'm using Selenium RC and had a similar problem few days ago. It took me ages to find the right way of doing it so I thought I will share the solution that worked for me:
(NOTE: I couldn't use $find)
The javascript to set the date on the RadDatePicker is:
var appBrowser = this.browserbot.getCurrentWindow();
var datepicker = appBrowser.yourDatePickerId; //note: no quotes
var selectDate=new Date();
selectDate.setFullYear(yourYear,yourMonth,yourDay);
datepicker.SetDate(selectDate);
datepicker.DateInput.SetDate(selectDate);
and then use selenium GetEval in your test to call javascript code to set the date:
selenium.GetEval("javascript here");
You should definitely wrap it around some parametrised helper class that will generate the javascript code for you each time you want to set the date in the test by passing id of the control and date.
I finally have a solution that works. The key is to use javascript to call the client-side API for the telerik control. The same technique is required for all complex Telerik controls, e.g. RadInput.
I used the technique recommended on the WatiN website for writing your own control http://watinandmore.blogspot.com/2009/12/wrapping-complex-logic-in-control.html to come up with this:
public class TelerikDatePicker : Control<TextField>
{
public DateTime? Value
{
get
{
var jScript = string.Format(#"$find(""{0}"").get_selectedDate();", Element.Id);
var selectedDateStr = Eval(jScript);
return TranslateJavascriptDateStringIntoDateTime(selectedDateStr);
}
set
{
var jScript = string.Format(#"$find(""{0}"").set_selectedDate(new Date(""{1:MMMM dd,yyyy}""));", Element.Id, value);
Eval(jScript);
}
}
public void SetValue(DateTime? value)
{
if (value.HasValue)
Value = value.Value;
else
Clear();
}
public void Clear()
{
var jScript = string.Format(#"$find(""{0}"").clear();", Element.Id);
Eval(jScript);
}
private string Eval(string script)
{
return Element.DomContainer.Eval(script);
}
public bool IsEnabled()
{
var jScript = string.Format(#"$find(""{0}"").get_enabled();", Element.Id);
return Eval(jScript) == "true";
}
private DateTime? TranslateJavascriptDateStringIntoDateTime(string jsDateStr /*E.g. Mon Mar 12 00:00:00 UTC+0100 2012*/)
{
if (String.IsNullOrEmpty(jsDateStr) || jsDateStr == "null") return null;
var abbreviatedMonth = jsDateStr.Substring(4, 3);
var dayOfTheMonth = jsDateStr.Substring(8, 2).TrimEnd(' ');
var year = jsDateStr.Substring(jsDateStr.Length-4, 4);
const string format = "d MMM yyyy";
var dateStr = dayOfTheMonth + " " + abbreviatedMonth + " " + year;
return DateTime.ParseExact(dateStr, format, CultureInfo.InvariantCulture);
}
}
I had the same issue with a RadDatePicker that would post back empty after typing in values.
I managed to automate typing in the date into the input field with these steps:
Select the dateInput text box associated with the control.
Do a dateInput.MouseClick() on it
Type the date into the field Manager.Desktop.KeyBoard.TypeText("1/1/1990")
Do a .MouseClick() on any other element on the page, e.g. some div
I found that #4 was needed to fire the events to make the control blur therefore "saving" its value.
Then you can submit and the value should go along with it.
Solved that problem for SeleniumIDE - you have to use "fireEvent" method with value "blur" for "ControlID" after you've set value using "sendKeys" or "type" methods. Strange that this problem does not occur when automating with WebDriver.
I'm using Visual Studio 2010 and i'm developing a windows form. Right now I'm using a data grid view and i want to write some functions that would allow you to automaticlly edit the datagrid by just changing the text in the Datagrid view. Right now, I am able to get the actual value but I need the value of the column in order to use it as a parameter when i use ADO.net here's what my code looks like now
private void dgv_DataLookup_CellValueChanged(object sender, DataGridViewCellEventArgs e)
{
DialogResult dr;
dr = MessageBox.Show("Are you sure you want to edit this field?", "Edit Cell", MessageBoxButtons.YesNo);
if (dr == DialogResult.Yes)
{
DataGridViewCell editItemCell = dgv_DataLookup[dgv_DataLookup.CurrentCell.RowIndex, dgv_DataLookup.CurrentCell.ColumnIndex];
string editItem = editItemCell.Value.ToString();
}
}
this here gets me the value of the current cell that is currently selected. I tried doing something like this
DataGridViewColumns columnCells = dgv_DataLookup.CurrentCell.ColumnIndex.Value.ToString()... something that would represent this but actual code. thanks!
According to what I understand you want to edit the value within a field, you can choose the value in this way.
private void button2_Click(object sender, EventArgs e)
{
if (MessageBox.Show("Are you sure you want to edit this field?",Application.ProductName.ToString(),MessageBoxButtons.YesNo)== DialogResult.Yes)
{
string editItem = this.dataGridView1.Rows[this.dataGridView1.CurrentRow.Index].Cells["NameField"].Value.ToString();
}
}
Bye
I want to use a date and time picker in a BlackBerry app.
Use net.rim.device.api.ui.component.DateField.
long yourInitialDatetime = System.currentTimeMillis();
DateField dateField = new DateField("Date:", yourInitialDatetime,
DateField.DATE_TIME);
yourScreen.add(dateField);
...
long currentlySelectedDatetime = dateField.getDate();
Also, see BlackBerry - Creating custom Date Field
I don't know if you still have this problem but the solution I used is the DateTimePicker Here's how you do it:
Calendar _dateCal;
SimpleDateFormat _dateFormat = new SimpleDateFormat("dd-MMM-yyyy");
DateTimePicker _datePicker = DateTimePicker.createInstance(_dateCal, "dd-MMM-yyyy", null);
if(_datePicker.doModal())
{
StringBuffer _dateStr = new StringBuffer();
_dateCal = _datePicker.getDateTime();
_dateFormat.format(_dateCal, _dateStr, null);
_setDateButton.setLabel(_dateStr.toString());
}
That will prompt a spinner box for date selection to the screen
well the problem is that i am trying to get DDL to:
1. Recive catagories from a DB tabel - working
2. OnChange select from a different table the products by the item in the DDL - working
had a problem with No1 but fixed that problem. i found out that to get No1 working i have to use postback. did that and every thing in that part is working well and actualy every thing is working...but my hug problem (and i cant find any good answer for it) is that every time i change the item i a getting all the times all over again(i have initialy 8 item - secont time 16 - 24 etc....)
tried to use: ddlCatagories.Items.Clear();
when i use that i am not getting any duplicates but then, i am not getting any thing, it takes the first catagory from the list every time, no matter what i chose in the list..
trying to figure it out for the past week...please help :-)
public partial class selectNamesFromCatagories : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
ddlCatagories.Items.Clear();
SqlDataReader dr = DbHelper.ExecuteReader(
sqlConn1.home,
"spSelectNamesFromCatagories");
while (dr.Read())
{
ListItem li = new ListItem(dr["CategoryName"].ToString());
ddlCatagories.Items.Add(li);
}
dr.Close();
}
protected void ddlCatagories_SelectedIndexChanged(object sender, EventArgs e)
{
SqlDataReader dr = DbHelper.ExecuteReader(
sqlConn1.home,
"spProductsByCatagoryID",
new SqlParameter("#catName", ddlCatagories.Text)
);
while (dr.Read())
{
TableRow tr = new TableRow();
for (int i = 0; i < dr.FieldCount; i++)
{
TableCell td = new TableCell();
td.Text = dr[i].ToString();
tr.Controls.Add(td);
}
tblProductsByCatagories.Controls.Add(tr);
}
}
}
Only populate the DropDownList on first load by checking whether the page has not posted back ie.
if (!Page.IsPostBack)
{
// Populate list
}
I agree with Dan and would add the following as well if you have any ajax enabled controls as they may generate callbacks.
if (!Page.IsPostBack && !Page.IsCallBack)
{
// Populate list
}