Click here to Skip to main content
15,885,546 members
Please Sign up or sign in to vote.
2.33/5 (3 votes)
See more:
hi dear!
i am developing an application to save some timings using datetimepikcer.
but the issue is.
i am not able to access datetimepicker name or its value in .cs file.

if any idea pleas help

THANX

M USman
Posted
Comments
Suvabrata Roy 28-Dec-12 0:55am    
Please provide some code sample...
Sergey Alexandrovich Kryukov 28-Dec-12 0:58am    
Not clear. A DateTimePicker is used for picking a time, not for saving. :-)

"Name or its value"? Sounds like you have no clue what are main programming entities: types, objects (instances), references, variables, names... I would suggest you learn it all on some more simple examples, without any UI...

—SA

Hi,
I think those will help you

Solution in Windows :

C#
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;

namespace TimePickerApplication
{
    public class Form1 : Form
    {
        public Form1()
        {
            InitializeTimePicker();
        }
        private DateTimePicker timePicker;

        private void InitializeTimePicker()
        {
            timePicker = new DateTimePicker();
            timePicker.Format = DateTimePickerFormat.Time;
            timePicker.ShowUpDown = true;
            timePicker.Location = new Point(10, 10);
            timePicker.Width = 100;
            Controls.Add(timePicker);
        }
        [STAThread]
        static void Main()
        {
            Application.EnableVisualStyles();
            Application.Run(new Form1());
        }

    }
}


Solution in Web

DateTimePicker Web Control[^]
 
Share this answer
 
Hi dear i found what the exact issue was.
in properties window i select the property

GenerateMember=false
when i set this property true

GenerateMember=true

i am able to access this in .cs file.

thanx for helping

specail thanx to
Suvabrata Roy
 
Share this answer
 
Comments
Suvabrata Roy 28-Dec-12 2:13am    
You most welcome...
Yes dear thanx

you answer is 100% correct
I also tried like this it is working but the issue is

Why i am not able to access datetimepicker value which added using tools(drag drop).


Thanx
 
Share this answer
 
Comments
Suvabrata Roy 28-Dec-12 1:06am    
So you are working with windows app?

Right Click on DateTime Picker go to properties go to name, then try to write the code with that name, you can face some cross thread access problem if you trying to access that from other than main thread, then use delegates or MethodInvoke delegate
Some code example is here?
pleas take a look

private void btnSave_Click(object sender, EventArgs e)
       {
           DialogResult dr = MessageBox.Show("Are you sure! you want to save changes of prayer timings", "Prayer Timings", MessageBoxButtons.YesNo, MessageBoxIcon.Question);
           if (dr == DialogResult.Yes)
           {
               btnModify.Visible = true;
               btnSave.Visible = false;
               if(!Directory.Exists(Application.StartupPath + "\\PrayerTimings"))
                   Directory.CreateDirectory(Application.StartupPath + "\\PrayerTimings");
               StreamWriter writer = new StreamWriter(Application.StartupPath + "PrayerTimings");
               string strFajar = dtPickerFajar.value?????       //here i want to access value of dtPickerFajar values which is not accessable
               string strZohar = dtPickerZohar.value?????         //5 more same not accessable
                   //

           }
       }
 
Share this answer
 
Comments
Suvabrata Roy 28-Dec-12 2:06am    
If you have any query please write in comments area not in solution.
Enjoy Coding... :)
private void btnSave_Click(object sender, EventArgs e)
{
DialogResult dr = MessageBox.Show("Are you sure! you want to save changes of prayer timings", "Prayer Timings", MessageBoxButtons.YesNo, MessageBoxIcon.Question);
if (dr == DialogResult.Yes)
{
btnModify.Visible = true;
btnSave.Visible = false;
if(!Directory.Exists(Application.StartupPath + "\\PrayerTimings"))
Directory.CreateDirectory(Application.StartupPath + "\\PrayerTimings");
StreamWriter writer = new StreamWriter(Application.StartupPath + "PrayerTimings");
string strFajar = dtPickerFajar.value.ToString("dd MMM yyyy"); //here i want to access value of dtPickerFajar values which is not accessable
string strZohar = dtPickerZohar.value.ToString("dd MMM yyyy"); //5 more same not accessable
//

}
}
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900