|
|
hi all,
below is my aspx code
<pre lang="HTML"><MKB:TimeSelector ID="TimeFrom" runat="server" DisplaySeconds="False">
</MKB:TimeSelector></pre>
and a text box which is having a date.
<pre lang="HTML">VehicleBookingDate.Text</pre>
I want to save date and time in my database. for that if I want to do like below
<pre lang="HTML"> string t1 = tsTimeFrom.Hour.ToString() + ":" + tsTimeFrom.Minute.ToString() + " " + tsTimeFrom.AmPm.ToString();
DateTime Time_From = Convert.ToDateTime(t1);</pre>
It saves time with current date, where as I want to save this time with this date which is in VehicleBookingDate.Text.
how can I do that.
Thanks
|
|
|
|
|
Now I get this
<pre lang="c#">
string t1 = Vehicle_Booking_Date.ToShortDateString() +" "+ tsTimeFrom.Hour.ToString() + ":" + tsTimeFrom.Minute.ToString() + " " + tsTimeFrom.AmPm.ToString();</pre>
that is a string but I want to save it as a datetime with the same date which Vehicle_Booking_Date variable is having
|
|
|
|
|
Don't use a TextBox, use a Calendar control[^]. You can then create a DateTime object from the two elements.
Use the best guess
|
|
|
|
|
I have Windows 7 64-bit and Excel 2010 32bit
I have the following question: I created an user defined functions for Excel in .NET according to the code http://blogs.msdn.com/b/eric_carter/archive/2004/12/01/writing-user-defined-functions-for-excel-in-net.aspx[^]
I'm using now MultiplyNTimes in my Excel 2010 spreadsheet.
if in the cell A1 i type =MultiplyNTimes(2,3,4) i get the correct results (162)
if in the cell A1 i type =MultiplyNTimes(B2,3,4) and I type 2 in cell B2, then I get #VALUE!
Basically my UDF can't accept a link to a cell as argument... can this bug be connected with 64 bit of Windows?
(note thae using the same OS with in 2007 works fine!)
not sure I'm clear.
Have you any suggestion to fix this bug?
Thanks for your time
|
|
|
|
|
PozzaVecia wrote: Basically my UDF can't accept a link to a cell as argument... can this bug be
connected with 64 bit of Windows?
Nope. It works fine on Office 2007 (32-bit) running on Windows 7 64-bit.
Typically, bitness problems involving Office interop are because of a mismatch with Office, not with Windows. For example, trying to run 32-bit extension in 64-bit Office.
The only time I could get a "#VALUE" error to show up was when I didn't supply 3 arguments.
I used the article you linked to and copied the code exactly (except for changing the GUID) as well as the exact steps for registering the Add-In in Excel.
|
|
|
|
|
Quote:
Nope. It works fine on Office 2007 (32-bit) running on Windows 7 64-bit.
Yes I tested the same Excel 2007 32bit with Windows 7 64bit is fine..
I have the problem with Excel 2010 32bit with Windows 7 64bit. I thought It was a problem of bit because if I type argument in a cell the UDF does't work (I thought It was a bit conversion problem). While if I directly write arg in function it works.
I also create a function with no args and it works (Excel 2010). So the problem is linked to reading arg from other cells. Very strange
|
|
|
|
|
I don't have Office 2010, so I can't test against that.
|
|
|
|
|
Hi All,
I have started using Visual Studio 2012 with C# as basic settings. But when I opened a project using Visual Studio 2012, I am not finding Solution Explorer in the ToolBar list on the top of the IDE, generally in Visual Studio 2010 I used to click on that Icon on the top of the IDE just below the File, Edit etc menu.
Can someone please help me in adding that to the list so that my development would become easy intead of going to View menu and selecting the Solution Explorer every time. I have checked to customize that ToolBar on the top, but I dont know which ToolBar item would add the Solution Explorer to ToolBar actually.
Thanks for the help in advance.
Thanks & Regards,
Abdul Aleem Mohammad
St Louis MO - USA
|
|
|
|
|
There isn't a button as far as I can tell.
I just use the quicker shortcut: Ctrl-W, S.
Or just click the View menu, Solution Explorer.
|
|
|
|
|
Another shortcut ctrl + alt + L
Do not go where the path may lead. Go instead where there is no path and leave a trail.
|
|
|
|
|
Click the drop down at the end of the Standard toolbar, and select "Add or Remove Buttons". It's in there.
|
|
|
|
|
Is there any need to use Visual Studio 2012, as there are some features that you won't find in VS 2012.
|
|
|
|
|
Member 10036172 wrote: Is there any need to use Visual Studio 2012, as there are some features that you won't find in VS 2012.
Like what?
Plus, this question has already been answered so your comment isn't particularly helpful.
|
|
|
|
|
I've come across with this progress bar using worker.ReportProgress(). I was hoping to get a real-time progress Bar value from outside Write_Tag method. In this code below, it does seem to have some 1-2 seconds delay before showing the progress bar status.
Any suggesion?
private void InitializeProgressBars()
{
for (int i = 0; i < DevicePath.Count; i++)
{
progressBar[i] = new ProgressBar();
progressBar[i].Location = new Point(3, 16);
progressBar[i].Size = new Size(605, 31);
progressBar[i].Maximum = 100;
}
gbProgressStatus0.Controls.Add(progressBar[0]);
gbProgressStatus1.Controls.Add(progressBar[1]);
gbProgressStatus2.Controls.Add(progressBar[2]);
gbProgressStatus3.Controls.Add(progressBar[3]);
}
private void InitializeBackgroundWorkers()
{
for (var f = 0; f < DevicePath.Count; f++)
{
bw[f] = new BackgroundWorker();
bw[f].WorkerReportsProgress = true;
bw[f].WorkerSupportsCancellation = true;
switch (f)
{
case 0:
{
bw[f].DoWork += new DoWorkEventHandler(BackgroundWorkerFilesDoWork0);
bw[f].RunWorkerCompleted += new RunWorkerCompletedEventHandler(BackgroundWorkerFilesRunWorkerCompleted0);
break;
}
case 1:
{
bw[f].DoWork += new DoWorkEventHandler(BackgroundWorkerFilesDoWork1);
bw[f].RunWorkerCompleted += new RunWorkerCompletedEventHandler(BackgroundWorkerFilesRunWorkerCompleted1);
break;
}
case 2:
{
bw[f].DoWork += new DoWorkEventHandler(BackgroundWorkerFilesDoWork2);
bw[f].RunWorkerCompleted += new RunWorkerCompletedEventHandler(BackgroundWorkerFilesRunWorkerCompleted2);
break;
}
case 3:
{
bw[f].DoWork += new DoWorkEventHandler(BackgroundWorkerFilesDoWork3);
bw[f].RunWorkerCompleted += new RunWorkerCompletedEventHandler(BackgroundWorkerFilesRunWorkerCompleted3);
break;
}
}
}
bw[0].ProgressChanged += (sender, e) => { progressBar[0].Value = e.ProgressPercentage; };
bw[1].ProgressChanged += (sender, e) => { progressBar[1].Value = e.ProgressPercentage; };
bw[2].ProgressChanged += (sender, e) => { progressBar[2].Value = e.ProgressPercentage; };
bw[3].ProgressChanged += (sender, e) => { progressBar[3].Value = e.ProgressPercentage; };
}
private void BackgroundWorkerFilesDoWork0(object sender, DoWorkEventArgs e)
{
BackgroundWorker worker = sender as BackgroundWorker;
ProgressBar pb = new ProgressBar();
pb.Maximum = 100;
worker.ReportProgress(0);
System.Diagnostics.Stopwatch sw = new System.Diagnostics.Stopwatch();
sw.Start();
int status = tag_device0.Write_Tag(0, writeDat, en_statusDat, pb);
worker.ReportProgress(pb.Value);
if (ReadTag)
{
worker.ReportProgress(0);
byte[] tagData = new byte[1024];
tag5_device0.Read_Tag(0, 0, tagData .Length, ref tagData , pb);
worker.ReportProgress(pb.Value);
}
sw.Stop();
string result = string.Format("Status: {0} Elapsed: {1}", status, sw.Elapsed.ToString());
e.Result = result;
}
|
|
|
|
|
Blubbo wrote: Any suggesion? It seems to do an update only twice?
int status = tag_device0.Write_Tag(0, writeDat, en_statusDat, pb);
worker.ReportProgress(pb.Value);
if (ReadTag)
{
worker.ReportProgress(0);
byte[] tagData = new byte[1024];
tag5_device0.Read_Tag(0, 0, tagData .Length, ref tagData , pb);
worker.ReportProgress(pb.Value);
}
FWIW; the more often you report progress, the longer it'll take to complete the task.
Bastard Programmer from Hell
If you can't read my code, try converting it here[^]
|
|
|
|
|
(This looks like Windows Forms vs. WPF.)
In the ...DoWorkn() method you create a local ProgressBar that is passed to the Write_Tag and Read_Tag methods.
There's not a tight linkage between that ProgressBar and the one that ReportProgress() is updating, so the one that is actually visible is not updated very often.
If the Write_Tag and Read_Tag methods aren't careful to deal with possible cross-thread updating of the ProgressBar passed to them, then you're kind of out-of-luck. It doesn't appear that there's an event on the ProgressBar that could be used to redirect the updates to the .Value to use the worker.ReportProgress(..) .
If the Write_Tag and Read_Tag methods are dealing with the cross-thread updating correctly, then you can pass the visible ProgressBar into the BackgroundWorker with the argument to the RunWorkerAsync(progressBar[n]) and use the ReportProgress() when updating directly in the worker, and pass it into the Write_Tag and Read_Tag methods, counting on them to "do the right thing" when they update it. Something like:
private void InitializeProgressBars()
{
for (int i = 0; i < DevicePath.Count; i++)
{
progressBar[i] = new ProgressBar();
progressBar[i].Location = new Point(3, 16);
progressBar[i].Size = new Size(605, 31);
progressBar[i].Maximum = 100;
}
gbProgressStatus0.Controls.Add(progressBar[0]);
gbProgressStatus1.Controls.Add(progressBar[1]);
gbProgressStatus2.Controls.Add(progressBar[2]);
gbProgressStatus3.Controls.Add(progressBar[3]);
}
private void InitializeBackgroundWorkers()
{
for (var f = 0; f < DevicePath.Count; f++)
{
bw[f] = new BackgroundWorker();
bw[f].WorkerReportsProgress = true;
bw[f].WorkerSupportsCancellation = true;
switch (f)
{
case 0:
{
bw[f].DoWork += new DoWorkEventHandler(BackgroundWorkerFilesDoWork0);
bw[f].RunWorkerCompleted += new RunWorkerCompletedEventHandler(BackgroundWorkerFilesRunWorkerCompleted0);
break;
}
case 1:
{
bw[f].DoWork += new DoWorkEventHandler(BackgroundWorkerFilesDoWork1);
bw[f].RunWorkerCompleted += new RunWorkerCompletedEventHandler(BackgroundWorkerFilesRunWorkerCompleted1);
break;
}
case 2:
{
bw[f].DoWork += new DoWorkEventHandler(BackgroundWorkerFilesDoWork2);
bw[f].RunWorkerCompleted += new RunWorkerCompletedEventHandler(BackgroundWorkerFilesRunWorkerCompleted2);
break;
}
case 3:
{
bw[f].DoWork += new DoWorkEventHandler(BackgroundWorkerFilesDoWork3);
bw[f].RunWorkerCompleted += new RunWorkerCompletedEventHandler(BackgroundWorkerFilesRunWorkerCompleted3);
break;
}
}
bw[f].ProgressChanged += (sender, e) => { ((ProgressBar)e.Argument).Value = e.ProgressPercentage; };
}
}
private void BackgroundWorkerFilesDoWork0(object sender, DoWorkEventArgs e)
{
BackgroundWorker worker = sender as BackgroundWorker;
worker.ReportProgress(0);
ProgressBar pb = (ProgressBar)e.Argument;
System.Diagnostics.Stopwatch sw = new System.Diagnostics.Stopwatch();
sw.Start();
int status = tag_device0.Write_Tag(0, writeDat, en_statusDat, pb);
if (ReadTag)
{
worker.ReportProgress(0);
byte[] tagData = new byte[1024];
tag5_device0.Read_Tag(0, 0, tagData .Length, ref tagData , pb);
}
sw.Stop();
string result = string.Format("Status: {0} Elapsed: {1}", status, sw.Elapsed.ToString());
e.Result = result;
}
bw[n].RunWorkerAsync(progressBar[n]);
Another design option, if you can change the Write_Tag and Read_Tag methods, would be to have them take an Action<int> delegate that deals with updating progress, instead of the ProgressBar . In this case, it would call worker.ReportProgress() .
|
|
|
|
|
I have came up with a solution before I saw this reply with Action<int>. I placed a new method in the class (same class with Read_Tag method in it). Works gracefully!
void UpdateProgressBar(ProgressBar pb, int value)
{
if (pb.InvokeRequired)
{
Action<ProgressBar, int> action = new Action<ProgressBar, int>(UpdateProgressBar);
object[] obj = new object[] { pb, value };
pb.BeginInvoke(action, obj);
}
else
pb.Value = value;
}
public int tag5_device0.Read_Tag(<parameters>, ProgressBar pb)
{
for (int i = 0; i < 44; i++)
{
UpdateProgressBar(pb, i);
}
|
|
|
|
|
I think you should just create the delegate once as it doesn't change. And the BeginInvoke 's second argument is params so it will assemble the object array automatically, so this might be easier to read:
private static Action<ProgressBar, int> UpdateProgressBarAction = UpdateProgressBar;
private static void UpdateProgressBar(ProgressBar pb, int value)
{
if (pb.InvokeRequired)
{
pb.BeginInvoke(UpdateProgressBarAction, pb, value);
}
else
pb.Value = value;
}
You could even use a lambda to define this self-referentially to avoid the separate UpdateProgressBarAction :
private static Action<ProgressBar, int> UpdateProgressBar = (ProgressBar pb, int value) => {
if (pb.InvokeRequired)
{
pb.BeginInvoke(UpdateProgressBar, pb, value);
}
else
pb.Value = value;
};
|
|
|
|
|
Thanks for the suggestion.
I'm still working on using the delegation of the code. I have never used it in my prior programs that I have created. Still learning new stuff.
Thanks again!
|
|
|
|
|
How To Calculate The Total Data Download in c#
|
|
|
|
|
Use a timer.
Use the best guess
|
|
|
|
|
|
Between us we could come up with some numbers.
Use the best guess
|
|
|
|
|
You need to create a small program in C# for calculating total downloaded data ?
|
|
|
|