|
My vote goes to NDoc[^].
Hope that helps a bit.
--Jesse
|
|
|
|
|
|
Excellent. Thanks.
Anyone who thinks he has a better idea of what's good for people than people do is a swine.
- P.J. O'Rourke
|
|
|
|
|
Hi,
How can I check for an Empty Dataset after calling filled property in DataAdapter.
Can I use
if (dsEmployee == Null)
will this work?
Thanks,
JJ
|
|
|
|
|
An empty DataSet isn't null. A DataSet variable is null when it reference nothing. There's a big difference.
If you want to determine if a DataSet is empty, you need to enumerate the tables and get the count of each table. This is the only way to account for both types of DataSet s - typed and untyped (generated by a DataAdapter , for example):
public bool IsEmpty(DataSet ds)
{
if (ds == null) throw new ArgumentNullException("ds");
foreach (DataTable dt in ds.Tables)
if (dt.Rows.Count > 0) return false;
return true;
} Optionally, if you want to treat a null reference as an empty DataSet (not really a good idea, but it's up to you), then replace the first line with something like if (ds == null) return true; .
Software Design Engineer
Developer Division Sustained Engineering
Microsoft
[My Articles]
|
|
|
|
|
Hi,
I have a Windows Form, which has multiple ListBoxes, being populated by data on FormLoad Event, and a Button to run the query. onClick of the button, I want to get all the selected values from the ListBoxes and form a Query String, with commas in between values, How can i Do That ??
Any help is appreciated.
Thanks,
Abhi
|
|
|
|
|
That really a fairly simple problem. You can get one or multiple values using ListBox.SelectedItems . Enumerate that property collection to get values. For each ListBox , you do this again. How you construct the query is up to you, but string concatenation, String.Concat , StringBuilder.Append , and many other ways can help you.
Software Design Engineer
Developer Division Sustained Engineering
Microsoft
[My Articles]
|
|
|
|
|
C# WinForms - DateTimePicker (VS 2003)
I have certain dates that are valid – can be non-contiguous(1,
5,13,17,22 of Aug’2004) or a continuous date range (10 – 17 Aug 2004). I need to
Disable the invalid dates – so that user may not choose unlisted
dates.
Visually show that these dates are not available (different fore
color, back color, or strike out font style etc)
Things that already tried. – Setting Min/Max date: works fine if the valid date range is continuous – user is then not able to click on invalid dates that are out of min/max range – but visually there is no indication and the user thinks the calendar is not working fine. Unable to set CalendarFont strike through for selected dates once the calendar dropdown occurs.
|
|
|
|
|
You need to customize the Month Calendar Control, actually. One way - perhaps the easiest - is to derive a class from DateTimePicker , like CustomDateTimePicker or something.
Define a property or properties to reflect MonthCalendar.AnnuallyBoldedDates and MonthCalendar.BoldedDates (depending on if you want dates reoccurring per year). You'll actually declare fields to store these values however:
private DateTime[] annuallyBoldedDates;
private DateTime[] boldedDates;
public DateTime[] AnnuallyBoldedDates
{
get { return annuallyBoldedDates; }
set { annuallyBoldedDates = value; }
}
public DateTime[] BoldedDates
{
get { return boldedDates; }
set { boldedDates = value; }
} Override OnDropDown and get the handle to the MonthCalendar and set its properties accordinly control like so:
protected override void OnDropDown(EventArgs e)
{
base.OnDropDown(e);
MonthCalendar mc = GetMonthCalendar();
if (mc != null)
{
mc.AnnuallyBoldedDates = annuallyBoldedDates;
mc.BoldedDates = boldedDates;
}
} You need to define GetMonthCalendar , though. This handle is only valid for that drop down, so you don't want to keep a reference to it. This is documented in the Common Controls documentation, which almost all of the Windows Forms controls encapsulate.
You could define what you need like so:
[DllImport("user32.dll")]
private static extern IntPtr SendMessage(IntPtr hWnd, int msg, IntPtr wParam, IntPtr lParam);
private const int DTM_GETMONTHCAL = 0x1008;
private MonthCalendar GetMonthCalendar()
{
IntPtr hWnd = SendMessage(this.Handle, DTM_GETMONTHCAL, IntPtr.Zero, IntPtr.Zero);
if (hWnd != IntPtr.Zero)
return Control.FromHandle(hWnd) as MonthCalendar;
} Read the documentation for MonthCalendar.AnnuallyBoldedDates and MonthCalendar.BoldedDates for more information.
Software Design Engineer
Developer Division Sustained Engineering
Microsoft
[My Articles]
|
|
|
|
|
Thanks Heath
That's exactly the approach I took after posting this query. Initially I kept struggling with the DateTimePicker – but realized the stuff that I need is actually possible in MonthCalendar. So now I’m, using Label Control to display the date range, OnClick of Label will show the MonthCalendar with all the Valid dates in BOLD. And still have the Min / Max dates so the user may not be able to click unwanted dates.
|
|
|
|
|
Hi,
I have a winform based user control and host it in IE using object tag. How do I hook up custom events exposed by the control via jscript. Is it possible?
Note: it is a winform based control, not an ASP.NET server control.
Thanks
|
|
|
|
|
Could you give an example of what events you are trying to hook up?
- Nick Parker My Blog | My Articles
|
|
|
|
|
Any standard .NET event.
Something like:
public class control : System.Windows.Forms.UserControl
{
public event EventHandler myEvent;
}
I want to use jscript to hook up a handler with myEvent, much like the old "onClick = "myClick"
The control is embedded using <object> tag.
|
|
|
|
|
Have you tried setting the value of the event within the object tag to what you want it to hook up to within your JavaScript code? I know you can set properties this way.
- Nick Parker My Blog | My Articles
|
|
|
|
|
The event needs to be declared right, though. Script can't simply hook-up to events when exposing your control to COM. See my reply to his post for a link back to a very old article on a site I'm sure you'll remember.
Software Design Engineer
Developer Division Sustained Engineering
Microsoft
[My Articles]
|
|
|
|
|
Heath Stewart wrote:
link back to a very old article on a site I'm sure you'll remember
Ah, the old days....I don't miss them one bit!
- Nick Parker My Blog | My Articles
|
|
|
|
|
You need to specify a source event implementation via the ComEventInterfaceAttribute on your class. See an older article of mine for details: User Controls for Windows and the Web[^].
You should also make sure your class interface is not auto-generated (use ClassInterfaceType.None for your class's ClassInterfaceAtribute ), define your class interface explicitly (implement it as the first interface in your class to be the class interface), and make sure it derives from IDispatch by attributing it with InterfaceType(ComInterfaceType.InterfaceIsIDispatch) , or use ComInterfaceType.InterfaceIsDual to support both late-binding and VTBL binding (IUnknown ).
If you don't follow the above guidelines (you would have to when writing COM objects in C++/MFC/ATL - it's no different here), you will have problems. Changing DISPIDs (see the DispIdAttribute ) may change and get cached incorrectly (depending on the container application or control), methods will get out of order (especially troublesome with VTBL binding) since .NET doesn't care about method order but VTBL binding in COM sure does, and more.
Software Design Engineer
Developer Division Sustained Engineering
Microsoft
[My Articles]
|
|
|
|
|
Thank you and Nick,
So about the security issue mentioned in your tutorial, do we have a reasonable solution yet?
Great tutorial, it helps a lot.
Thanks again.
|
|
|
|
|
Could you please be a little more specific? There's lots of security "issues" (not holes or anything, but things you must understand).
You might want to take a look at Understanding .NET Code Access Security[^] for a good overview of CAS and follow the links to MSDN for more detail.
Software Design Engineer
Developer Division Sustained Engineering
Microsoft
[My Articles]
|
|
|
|
|
I wanted to use a .mov file in my splash screen. Can anyone give me some pointers? Are any other video file formats easier to use?
|
|
|
|
|
You can use DirectX to include both audio and video playback. Read this[^] for more information. The only caveat is I am not aware that it will/won't play a .mov file.
- Nick Parker My Blog | My Articles
|
|
|
|
|
|
I was wondering what the pros and cons of using convert vs parse, as in
<br />
string s = "2";<br />
<br />
Convert.ToInt32(s);<br />
<br />
int.Parse(s);<br />
|
|
|
|
|
Probably the best way to anser that question is by writing a quick program.
Capture the time, do 1000 Convert.ToInt32();, capture the time,
do 1000 int.Parse(), capture the time. Then see if there is a difference worth noting.
This signature left intentionally blank
|
|
|
|
|
Hi!
I don´t know the exactly function of both methods, but there is one big difference.
I can´t explain it in words, just try following code:
using System;
using System.Globalization;
namespace DummyTest
{
///
/// Summary description for Class2.
///
public class Class2
{
[STAThread]
static void Main()
{
string test = "2,5";
try
{
double i = Convert.ToDouble(test);
Console.WriteLine(i);
double a = double.Parse(test, NumberStyles.Float);
Console.WriteLine(a);
}
catch (Exception err)
{
Console.WriteLine("Exception: ", err.Message);
}
}
Console.Readline();
}
}
So you can see, the Convert method try to convert equal what he gets, and with the parse method you are able to specify the input format.
Certainly there are more pro´s and con´s but I only know this one...
Norman-Timo
|
|
|
|