|
static bool isValidDueDate(DateTime receivedDate, DateTime dueDate)
{
if (receivedDate != null && dueDate != null)
{
return dueDate > receivedDate;
}
}
|
|
|
|
|
DaveyM69 wrote: if (receivedDate != null && dueDate != null)
null testing a data type?
Luc Pattyn [Forum Guidelines] [My Articles]
this weeks tips:
- make Visual display line numbers: Tools/Options/TextEditor/...
- show exceptions with ToString() to see all information
- before you ask a question here, search CodeProject, then Google
|
|
|
|
|
|
What is the difference between array and arraylist
Regards,
LEE
|
|
|
|
|
Array:The Array class is the base class for language implementations that support arrays. However, only the system and compilers can derive explicitly from the Array class. Users should use the array constructs provided by the language.An element is a value in an Array. The length of an Array is the total number of elements it can contain. The rank of an Array is the number of dimensions in the Array. The lower bound of a dimension of an Array is the starting index of that dimension of the Array; a multidimensional Array can have different bounds for each dimension.Type objects provide information about array type declarations. Array objects with the same array type share the same Type object.Type.IsArray and Type.GetElementType might not return the expected results with Array because if an array is cast to the type Array, the result is an object, not an array. That is, typeof(System.Array).IsArray returns false, and typeof(System.Array).GetElementType returns a null reference (Nothing in Visual Basic).Unlike most classes, Array provides the CreateInstance method, instead of public constructors, to allow for late bound access.The Array.Copy method copies elements not only between arrays of the same type but also between standard arrays of different types; it handles type casting automatically.Some methods, such as CreateInstance, Copy, CopyTo, GetValue and SetValue
Arraylist:The capacity of an ArrayList is the number of elements the list can hold. As elements are added to an ArrayList, the capacity is automatically increased as required through reallocation. The capacity can be decreased by calling TrimToSize or by setting the Capacity property explicitly.Indexes in this collection are zero-based.ArrayList accepts a null reference (Nothing in Visual Basic) as a valid value and allows duplicate elements.
|
|
|
|
|
In my application, if you check a checkbox, and then click a delete button, it deletes that data that was next to the checkbox(in my case labels, and the checkbox itself)
it works fine for the first time, if i choose something from the list to delete, it deletes it and the checkbox itself.
but! if i then choose another checkbox, and click delete it doesn't work(at the debugger i can see that it is like the checkbox is not checked, whilst the user checked it)
i guess i have a problem with the fact that its dynamic, but i can't find it
here is the code - long one, but the only relevant functions are DisplayData and DeleteData
please help me;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using System.IO;
using System.Collections;
namespace AutoDownloader
{
public partial class Form1 : Form
{
public Form1()
{
Initiailize();
}
public void Initiailize()
{
this.Width=800;
this.Height=400;
this.StartPosition= FormStartPosition.CenterScreen;
DisplayData();
Button UpdateList = new Button();
Button AddShow = new Button();
Button DeleteChecked = new Button();
AddShow.Click+=new EventHandler(AddShow_Click);
UpdateList.Click += new EventHandler(UpdateList_Click);
DeleteChecked.Click += new EventHandler(DeleteChecked_Click);
AddShow.Top = 300;
AddShow.Left = 20;
AddShow.Width = 100;
AddShow.Text = "Add New Show";
UpdateList.Top = 300;
UpdateList.Left = 150;
UpdateList.Text = "Update Show List";
UpdateList.Size = UpdateList.PreferredSize;
DeleteChecked.Top = 300;
DeleteChecked.Left = 270;
DeleteChecked.Text = "Delete Checked Shows";
DeleteChecked.Size = DeleteChecked.PreferredSize;
this.Controls.Add(DeleteChecked);
this.Controls.Add(AddShow);
this.Controls.Add(UpdateList);
}
public void DeleteChecked_Click(object sender, System.EventArgs e)
{
DeleteData();
DisplayData();
}
public void AddShow_Click(object sender, System.EventArgs e)
{
AddShowForm subform=new AddShowForm();
subform.ShowDialog();
}
public void UpdateList_Click(object sender, System.EventArgs e)
{
DisplayData();
}
CheckBox[] CheckBoxes; //the checkboxes that later will be initialized
StreamReader ShowDataFile;
Label[] LabelData;
public void DisplayData() // opens text file, reads the data into an array lists, and then creates the check boxes and labels and displays them.
{
ShowDataFile= File.OpenText("c:\\text.txt");
ArrayList ShowsData = new ArrayList();
string buffer;
while (((buffer = ShowDataFile.ReadLine()) != "" ) && ((buffer != null)))
{
ShowsData.Add(buffer);
}
ShowDataFile.Close();
LabelData = new Label[ShowsData.Count];
CheckBoxes= new CheckBox[ShowsData.Count];
int i;
int index = 0;
for (i = 0; i < ShowsData.Count; i += 4) //start the checkboxes;
{
CheckBoxes[index] = new CheckBox();
this.Controls.Add(CheckBoxes[index]);
index++;
}
for (i = 0; i < ShowsData.Count; i++) //loop that intiliazes the labels;
{ //reads the data into the labels, and adds the controls to the forms.
LabelData[i] = new Label();
LabelData[i].Text = (String)ShowsData[i];
this.Controls.Add(LabelData[i]);
}
int TopMargin = 20;
int LeftMargin = 20;
int label_index = 0;
int checkbox_index = 0;
for (i = 0; i < ShowsData.Count; i+=4 ) //adds checkbox for each 4 lines of array( one dataset)
{
CheckBoxes[checkbox_index].Top = TopMargin;
CheckBoxes[checkbox_index].Left = LeftMargin;
CheckBoxes[checkbox_index].Size = CheckBoxes[checkbox_index].PreferredSize;
for (int y = 0; y < 4 && label_index
|
|
|
|
|
Hai all,
i just want to know about Generic XL Upload with validations.
can some body send me sample urls
Thanks
Subbu.
|
|
|
|
|
Hi,
i need a idea for following requierment.
how to spilit the following text and html tags.
\r\n</td></tr><td valign=top width=8%><p>1.</p></td>\r\n<td><p align=left>\r\n\r\n\r\n\r\nThe patient is with HIV infection, which is undetectable. However, her CD4 count has gone down. We will change the Trizivir to Aila to take one a day and we will see her in about four months.</p>\r\n\r\n\r\n\r\n\r\n \r\n\r\n\r\n\r\n"
My Requierment is:
the above text coming from database in view mode it will be like this
1.
The patient is with HIV infection, which is undetectable. However, her CD4 count has gone down. We will change the Trizivir to Aila to take one a day and we will see her in about four months
then it will go to edit mode in this i have to restrict the tags.and allow the text to edit
and the submit click agian i have to add the html tags to text for alignment
Thank in advance
Revathi Raj
|
|
|
|
|
Just parse out the stuff you need. You can use regular expressions or string functions. Also, do not use words like "Very urgent" around here. Most members do not have a liking for that since we are all volunteering our time without pay.
"Try asking what you want to know, rather than asking a question whose answer you know." - Christian Graus
|
|
|
|
|
Short answer: no.
Regards,
mav
--
Black holes are the places where God divided by 0...
|
|
|
|
|
Thank you
|
|
|
|
|
Please don't delete your questions once they have been answered.
That's considered quite rude because that way the answers become meaningless and other users searching the forums can't learn from your question.
Regards,
mav
--
Black holes are the places where God divided by 0...
|
|
|
|
|
I wondered how this became headless. Didn't realize you could do that
|
|
|
|
|
Sorry Mate,
I will take care of it from the next time...
Thanks,
Kuldeep
|
|
|
|
|
give me sample codes in C# using the iterator
|
|
|
|
|
1) Look up the word "please" in your dictionary
2) Use the search function
3) Use meaningful headlines
Regards,
mav
--
Black holes are the places where God divided by 0...
|
|
|
|
|
|
Like mav.northwind said, say please, and also use google to search. If you have a question about iterators, ask. Don't just rudely demand sample code.
"Try asking what you want to know, rather than asking a question whose answer you know." - Christian Graus
|
|
|
|
|
I have a group box containing a rather complex grid of controls. When that group box resizes (as as a result of my form resizing), some rather complex and time consuming code runs to re-layout the controls.
Some of the more complex code can be skipped until after the user is done resizing the form - it is not necessary for this code to run while the user is still resizing, as he can still see where things will go.
How do I do this? Currently, I'm getting many many resize events as the user drags the edge of the form. How can I defer some of my actions until the resize is complete?
For instance, is there an event I can get once the resize is complete, that I *don't* get during the resize?
|
|
|
|
|
Hi!
You're asking for a way to decide whether or not the form is going to be resized in the near future (resizing still in progress) or not (resizing has finished). Time to polish your crystal ball
But you could use a timer to defer your code until resizing has stopped for a while. If another resize event occurs before the timer has fired, restart the timer. Once the timer fires, the last resize event lies a short while ago, so probably the user is done resizing - you can perform your layout.
Nevertheless, the user still can start resizing again while you're performing layout...
Regards,
mav
--
Black holes are the places where God divided by 0...
|
|
|
|
|
It's closer to "I want to know when the mouse comes up after resize", but without the complications of tracking the mouse, and the fact that resize can come from other sources than the mouse, etc.
I've seen the event structure I want in other places. Basically, I'd like a "Resize Just Completed" event, and perhaps "Mouse Resize Is Occuring, Mouse is Still Down, Here's Your New Dimensions" event to go along with that.
I believe that the reason they don't distinguish between them in .NET / Windows is so that legacy apps would redraw on the fly during a resize (since pre-Win95 windows only got the Resize event after the Resize was completed).
At any rate, I was hoping I was missing an easy method here, like a "Resize Completed" event, somewhere in all the Layout() hoopla. Having looked and tested, I don't think I can have what I want (without doing my own timer stuff, which is a nuisance and not worth it).
Thanks for the idea, though.
- The Lazy Coder
|
|
|
|
|
Although it's not directly exposed in the Form Properties window in VS 200x, if you look in MSDN you'll see that a form has multiple resizing events, exactly what you need:
Remarks
The ResizeBegin event is raised when the user begins to resize a form, typically by clicking and dragging one of the borders or the sizing grip located on the lower-right corner of the form. This action puts the form into a modal sizing loop until the resize operation is completed. Typically, the following set of events occurs during a resize operation:
1. A single ResizeBegin event occurs as the form enters resizing mode.
2. Zero or more pairs of Resize and SizeChanged events occur as the form's Size is modified.
3. A single ResizeEnd event occurs as the form exits resizing mode.
Note
Just clicking without dragging on a border or resizing grip will generate the ResizeBegin and ResizeEnd events without any intermediate Resize and SizeChanged event pairs.
The ResizeBegin and ResizeEnd pair of events is also raised when the user moves the form, typically by clicking and dragging on the caption bar. These events are not generated by programmatic manipulation of the form, for example by changing the Size or Location properties.
See for .Net 2.0: http://msdn2.microsoft.com/en-us/library/system.windows.forms.form.resizebegin(VS.80).aspx[^]
|
|
|
|
|
I need to execute my program, when i click the print button from any program (eg. MS word), I think it is not related to .NET, But if you have worked like that projects, please let me know.
Thank you.
Chatura Dilan
|
|
|
|
|
You want it to run whatever printer is used, or write a print driver.
Christian Graus - Microsoft MVP - C++
"I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )
|
|
|
|
|
Hello,
I know this may sound crazy but I just wanted to know if anyone can help me.
I'm creating a front-end style database management system, there is also functionality in the program to use the data etc but thats not important. What im trying to achieve is the addition of fields to tables in a database which is relativly easy, but I also want my classes that represnt tables in my database to have updated getter and setter functions.
I dont know if this is possible so that when a new field is added, i can write some code that will alter whatever.cs and add in new functionality to handle the new field. Thinking about it, i dont think it's possible - the only way i can imagine it is to run some sort of script whilst the program is not running to update the code?
Any suggestions if any of that made sense?
|
|
|
|
|