Format Time in Visual Studio Report Designer - visual-studio-2010

I have a time field in SQL server that I am trying to display on a rdlc report in visual studio. I would like it to be in HH:mm format but it continues to display as HH:mm:ss. The seconds portion is always zero and I don't want it shown. I thought this would be an easy format fix but none of my expressions seem to work.
Format(Fields!my_time.Value,"HH:mm")
Left(Fields!my_time.Value,5).ToString()
Hour(Fields!my_time.Value) + ":" + Minute(Fields!my_time.Value)
I've never used the report features in visual studio before so I'm hoping I'm missing something easy. Is there someplace other than the format property I should be trying these?

Assuming Fields!my_time is a DateTime field, you can do this:
Change the value of the control where this data is displayed to just use Fields!my_time.Value rather than an expression
Right-click the control and select Text Box Properties
Select Number, then Time in the Category list, then the time format you wish to use
This may give you better results than attempting to format through an expression.

Related

Visual Studio DateTime format in context menu

Pretty specific question, I guess, but is there a way to set the culture for the DateTime formatting in Visual Studio? My specific issue is that I do not live in one of the four countries that actually use PM/AM, so I can't ever remember which is which. Frankly, I don't care to either. Image here to show what I mean:
I just want the formatting to be a sensible 24-hour format instead. Anyone know how to accomplish this?

Saving array contents to file using Visual Studio immediate window

I am using Visual Studio 2017 and C++ to debug a huge project
I don't use it frequently so I am not sure if this is possible or not, but is there any way to save all the contents of an array to a file using the immediate window? I have been looking around to find out the capabilities of the immediate window but there doesn't seem to be any place where this is clearly explained
This page comes up on google which only says it's possible to display contents of a variable, but doesn't give much more information
By looking around stackexchange I have found that a range of values in an array can be displayed using something like
array_name, 10
which will show the first 10 elements of an array, and this answer says there is a way to simply direct the output in the immediate window to a file, but my array has thousands of elements, and the array_name, XX trick only displays first 100 elements on the array in the immediate window
Is there a straightforward way to save contents of a variable or array to file in Visual Studio 2017 while the program is at a breakpoint?
You can get the content of any variable by copying it out of the watch window. From there you can pasted it into a file. I don't think there's anything to write it to a file from VS. You could of course have your program do that.
To get the variable values to the clipboard add a watch expression for your variable in the watch window (it's along the bottom of VS). However, don't just copy the expression (as that will get capped) expand it out then select all (Ctrl+A) and then right click Copy Value and you should get it to the clipboard. Depending on the contents of your array there might be truncation.

CanGrow property does not work

I have a field that contain data with more than one line. I`m using VS 2010 and crystal report. The property CanGrow work fine in all records except last record it appear in one line. Look at the picture below.
Your field Normal Value is growing - we can see two lines. Maybe your surroundig box ist not respecting that increase in height.
Try checking Extend to Bottom of Section when printing of your surroundig box. Right-click your box, then select Format Box:

How do I get all labels from Visual Source Safe

Yes - still using Visual Source Safe.
I know you can 'get by label' when searching for specific label text. But I want to get all labels that were applied since a specific date. Can that be done?
Yes, it's doable. You can right-click $/, click Show History. In the History Options dialog, check 'Recursive', 'Includes Labels' + 'Labels Only', specify the time range and you should get the results you want.

Visual Studio 2008 Debug Window to display timestamp?

I want to be able to see a time stamp in the beginning of every trace in the debug window in Visual studio.
[Time stamp here] The thread 'Win32 Thread' (0xcd0) has exited with code 0 (0x0).
[Time stamp here] => CLR ProvideAssembly: AppDomainId: 1, Ref: 'msvcm90d...
Example of this is the sysinternals application - DebugView. The problem is that I can't have Visual Studio debugging, and listening with DebugView at the same time, and I am not comfortable with adding the time stamp manually to my tracers.
Since the output window text is read-only once written, there's not an easy way to do exactly what you want to do. However, it's easy to do something similar: append a timestamp line after new text is written to the output window. This will make the output window a lot more messy, but you'll get your timings.
Here's how this would work: First, create a Visual Studio Add-in or Macro which hooks the PaneUpdated event of the Outlook Window's active pane. (See this thread for how to do this with a Macro approach). Make sure to check, in the event handler, that pane.Name == "Debug" and ignore other panes. Second, when you detect new text in the debug output pane, append a timestamp line, like this:
public void AddTimestamp(DTE2 dte)
{
// Retrieve and show the Output window.
OutputWindow outWin = dte.ToolWindows.OutputWindow;
pane = outWin.OutputWindowPanes.Item("Debug");
}
catch
{
pane = outWin.OutputWindowPanes.Add("Debug");
}
pane.OutputString("[timestamp: " + DateTime.Now.ToString() + "]\n");
}
It's also possible to pre-pend a timestamp to each line, but it's a lot harder. You can't change text already in the Output window (it's read-only), but you can clear the window and you can add text. So you could use the same event-handler approach above to detect text changes, but instead of appending you could copy the current text, prepend timestamps to any lines which don't have timestamps already, clear the window, and re-add the now-with-timestamps text. The problem with this is performance once your output window gets large. So you'd probably have to implement a kind of "lazy stamping" which does the clear and insert in the background, in order to avoid killing your IDE when (as is common) 100's of lines of debug output get emitted in a short time. Also, when you clear and re-add, if you're currently selecting text in the output window, your selection is lost.
Personally, I'd just do the easy thing and append timestamp lines rather than the harder pre-pend approach. Since stuff at the end of the line is hard to see without scrolling, I'd probably ensure there was a newline before the timestamp, so the user would see each batch of one or more output lines followed by one timestamp line.
It's possible there may be a way to hook the output window before text is displayed, but I couldn't find any such extensibility point in the VS Extensibility APIs.
One more idea: you could always roll your own tool window, e.g. "Ivan's Debug Output" which listens to events coming from the real output window, and echoes new lines (with timestamps) to your own tool window. This is probably the hardest option, but should do exactly what you want.
to add a new answer to an ANCIENT question, there's an feature in the productivity power tools 2013 extension and productivity power tools 2015 extension that add a timestamp margin to the output window, no code required.
I was looking for the same functionality. Colleague of mine came up with the $TICK macro in the message field, printing out the 'current' cpu ticks.
Take a look at these tips from Simon Chapman, too.
I wanted this functionality too, so eventually I wrote an extension to do it (much like Justin Grant suggested in the accepted answer). After using it for a while, I decided that relative timestamps were even more useful to me when debugging. If folks wanted absolute timestamps, I'm sure I could add that functionality back in. Anyway, if you're interested you can check it out at niahtextfilter.com.
And to show the relative timestamps in action in a Visual Studio debug session:

Resources