|
It would probably easier to use something like a Hashtable
Arthur Dent - "That would explain it. All my life I've had this strange feeling that there's something big and sinister going on in the world."
Slartibartfast - "No. That's perfectly normal paranoia. Everybody in the universe gets that."
Deja View - the feeling that you've seen this post before.
|
|
|
|
|
i have never worked with hashtables before do they have some advantage over a datatables
|
|
|
|
|
Well, they do have a key that you can look up.
For instance:
private Hashtable _myTable = new Hashtable();<br />
<br />
public void AddItem(string value)<br />
{<br />
if (_myTable.Count > 0 && !_myTable.ContainsKey(value))<br />
_myTable.Add(value, value);<br />
}
Then, in your code you could do:
AddItem("Hello");<br />
AddItem("Hello 2");<br />
AddItem("Hello");
The list will only contain Hello and Hello 2. The last item will not be added.
Arthur Dent - "That would explain it. All my life I've had this strange feeling that there's something big and sinister going on in the world."
Slartibartfast - "No. That's perfectly normal paranoia. Everybody in the universe gets that."
Deja View - the feeling that you've seen this post before.
|
|
|
|
|
thanks alot for the help its appreciated i ended up using an arrayList to store the dates for each injury but ill def have a look at the hashtables
thanks again
private ArrayList AddDaysInjuredToArray(DateTime startDate, DateTime endDate, ArrayList dateList)
{
//*** set arraylist = to arraylist of days returned
dateList = AddDatesInBetween(startDate, endDate, dateList);
//*** sort arraylist making it easier to find duplicates
dateList.Sort();
//*** remove duplicates
for (int i = dateList.Count - 2; i >= 0; i--)
{
if ((DateTime)dateList[i] == (DateTime)dateList[i+1])
dateList.RemoveAt(i+1);
}
//*** return arrayList containing list of days injured with no duplicates
return dateList;
}
private ArrayList AddDatesInBetween(DateTime startDate, DateTime endDate, ArrayList dateList)
{
//*** start with day after startDate as startDate is not to be counted
DateTime newDate = startDate.AddDays(1);
//*** while newDate before endDate
while (newDate < endDate)
{
//*** add newDate to arraylist
dateList.Add(newDate);
//*** set newDate to next date
newDate = newDate.AddDays(1);
}
//*** return arrayList containing list of days injured
return dateList;
}
|
|
|
|
|
Hello All.
Some of you may have come across the problem when you have folder and file names in hebrew.
the problem is that the hebrew file name is replaced with it's parent folder when reading it into a string.
for example:
let's say i have a folder called c:\temp\סתם
and under this folder i have a file called משה.txt
when i read (using FileOpenDialog or any other technique) this full path into a string i expect to get:
c:\temp followed by a folder named סתם and a file named משה.txt but what you get is c:\temp\סתם\משה.txt
Does anyone know how to handle this?
Cheers
|
|
|
|
|
hi friends,
in my project i have to display a set of photos stored in a folder dynamically to the web page,
wat we did is that we have stored the path of a destination folder into a single column in SQL server and then we have to retrive all the photos stored in that specifeid folder to the web page....
i'm able to get the photos stored in it,
so can anyone help me out
thank you,
|
|
|
|
|
so what is the problem if you use the image control and
change the ImageUrl Property ??
Tamimi - Code
|
|
|
|
|
ya..thanks for reply..
but i have to get the url of each image dynamically and i have to diaplay all the images in that page
the page must look like the image galleries in the movie websites..
for example when you go for the wallpaers of a movie the corresponding images are loaded into the page..
that kind of output i want..
can u tell me how can i do it..
possible give me an example code...
|
|
|
|
|
do you know how to use the Repeater control ?? if you...
format your repeater as you wish, then on the ItemDataBound event
set the urls for you images
fell free to post again
Tamimi - Code
|
|
|
|
|
can you explain with an example for using the repeater control for my problem
|
|
|
|
|
And man no need to repost the same question in multiple forums..
Best Regards,
Apurva Kaushal
|
|
|
|
|
Hi,
I am invoking the delegates asynchronously(using Begin Invoke).
These delegates are not invoked in the invocation order .
How to make this delegate to raise in the invocation order.
Thanks in Advance
Sangeetha
|
|
|
|
|
I'm not sure you can control the order in which delegates are invoked.
Instead you could use a System.Timers.Timer object (which will execute on a thread pool thread) and a synchronized list of work items. You add work items to the list and the timer routine takes them off again.
|
|
|
|
|
Hi!
How can I achieve following in oracle with command?
select .. from .. where name in (:paramter)
THank you in advance!
|
|
|
|
|
i want to call matlab functions in c# program?is there any way to do it?
thanx
|
|
|
|
|
http://www.codeproject.com/dotnet/matlabeng.asp
does that help?
Russ
|
|
|
|
|
Clickety[^]
Tarakeshwar
MCP, CCIE Q(R&S)
Before you criticize someone, you should walk a mile in their shoes. That way, when you criticize them, you're a mile away and you have their shoes.
!sgub evah t'nseod margorp sihT ?sgub naem ayaddahW
|
|
|
|
|
Hi all,
I want my Console.WriteLine(...) output to be saved in a text file AS WELL AS displayed on the console screen.
I know how to get the output to go to the text file instead of the screen (use Console.SetOut to the stream provided by a new StreamWriter, say). But I can't get the output to go to BOTH!
I am probably being very stupid, and there is a simple answer, but all the google hits discuss the situation where you want the output to go to the text file instead of the console window.
Thanks for anything you can suggest!
Russ
|
|
|
|
|
How can we change the color of the scroll bar?
Thanks in advance.
Mandar
|
|
|
|
|
hi mandar,
try in this way
active-scroll-bars {
scrollbar-face-color: red;
scrollbar-track-color: blue;
}
regards,
Rahi
|
|
|
|
|
Whether you want to generate a dynamic function, write a dynamic algorithm or want to handle delegate inline, anonymous functions have always been at your service. However one area where in anonymous function lacking is, making a recursive call. Since it does not have function signature it’s not possible to make recursive call, at lease not directly. This article shows you how to achieve that.
See complete blog:
http://aamironline.com/blog/2006/10/29/recursive-call-with-anonymous-function.xml[^]
|
|
|
|
|
Why post this here? Why not make it into an Article? It seems like it would make an excellent article.
Arthur Dent - "That would explain it. All my life I've had this strange feeling that there's something big and sinister going on in the world."
Slartibartfast - "No. That's perfectly normal paranoia. Everybody in the universe gets that."
Deja View - the feeling that you've seen this post before.
|
|
|
|
|
|
Hi everyone!
My problem is that i have a user control. It has an ArrayList, in the ArrayList there is a collection of Buttons. I can set up these Buttons at designtime, but when I go to run the program, it seems to clear out my arraylist.
Why would it do this? Am I missing some vital bit of code that is needed in the transition from designtime to runtime. The code I use is below. Any help would be appreciated.
the hbHoverButton is another control of mine, but I assume that its the same problem even if I change the control.
Thanks
<br />
using System;<br />
using System.Collections;<br />
using System.ComponentModel;<br />
using System.Drawing;<br />
using System.Data;<br />
using System.Windows.Forms;<br />
<br />
namespace Toolbar<br />
{<br />
[ToolboxBitmapAttribute(typeof(Toolbar.tbToolbar), "tbToolbar.ico")]<br />
public class tbToolbar : System.Windows.Forms.UserControl<br />
{<br />
private System.Windows.Forms.Button cmdToolbar;<br />
private System.Windows.Forms.Panel pnlPanel;<br />
private System.ComponentModel.Container components = null;<br />
private HoverButton.hbHoverButton hbDefault;<br />
<br />
<br />
#region Variables<br />
private ArrayList alButtons = new ArrayList();<br />
private int mButtonHeight = 54;<br />
private string mToolbarText = "Toolbar";<br />
private ContentAlignment mButtonImageAlign = ContentAlignment.TopCenter;<br />
private ContentAlignment mButtonTextAlign = ContentAlignment.BottomCenter;<br />
private string mKey;<br />
#endregion<br />
<br />
<br />
#region Properties<br />
<br />
public Toolbar.clsHoverButtonProp[] ButtonItems<br />
{<br />
get<br />
{<br />
Toolbar.clsHoverButtonProp[] newImage = new Toolbar.clsHoverButtonProp[alButtons.Count];<br />
<br />
for(int i = 0; i < alButtons.Count; i++)<br />
{ <br />
HoverButton.hbHoverButton newHover = Button(i);<br />
newImage[i] = new Toolbar.clsHoverButtonProp();<br />
newImage[i].ButtonText = newHover.ButtonText;<br />
newImage[i].ButtonImage = newHover.ButtonImage;<br />
}<br />
<br />
return newImage;}<br />
set<br />
{<br />
alButtons.Clear();<br />
for(int i = 0; i < value.Length; i++)<br />
{<br />
Toolbar.clsHoverButtonProp newImage = new Toolbar.clsHoverButtonProp();<br />
newImage = value[i];<br />
<br />
HoverButton.hbHoverButton tbNewButton = new HoverButton.hbHoverButton();<br />
<br />
tbNewButton.ButtonText = newImage.ButtonText;<br />
tbNewButton.ButtonImage = newImage.ButtonImage;<br />
tbNewButton.Left = hbDefault.Left;<br />
tbNewButton.Width = pnlPanel.Width - 11;<br />
tbNewButton.ForeColor = Color.White;<br />
tbNewButton.Anchor = hbDefault.Anchor;<br />
tbNewButton.Visible = true;<br />
tbNewButton.Click += new EventHandler(HoverButton_Clicked);<br />
<br />
alButtons.Add(tbNewButton);<br />
<br />
}<br />
<br />
DisplayButtons();<br />
}<br />
}<br />
<br />
<br />
public int ButtonHeight<br />
{<br />
get { return mButtonHeight;}<br />
set <br />
{<br />
mButtonHeight = value;<br />
hbDefault.Height = mButtonHeight;<br />
DisplayButtons();}<br />
}<br />
<br />
<br />
public ContentAlignment ButtonImageAlign<br />
{<br />
get { return mButtonImageAlign;}<br />
set <br />
{<br />
mButtonImageAlign = value;<br />
DisplayButtons();}<br />
}<br />
<br />
<br />
public ContentAlignment ButtonTextAlign<br />
{<br />
get { return mButtonTextAlign;}<br />
set <br />
{<br />
mButtonTextAlign = value;<br />
DisplayButtons();}<br />
}<br />
<br />
<br />
public string ToolbarText<br />
{<br />
get { return mToolbarText;}<br />
set <br />
{<br />
mToolbarText = value;<br />
cmdToolbar.Text = mToolbarText;}<br />
}<br />
<br />
<br />
public Image ToolbarImage<br />
{<br />
get { return cmdToolbar.Image;}<br />
set { cmdToolbar.Image = value;}<br />
}<br />
<br />
<br />
public ContentAlignment ToolbarImageAlign<br />
{<br />
get { return cmdToolbar.ImageAlign;}<br />
set { cmdToolbar.ImageAlign = value;}<br />
}<br />
<br />
<br />
public ContentAlignment ToolbarTextAlign<br />
{<br />
get { return cmdToolbar.TextAlign;}<br />
set { cmdToolbar.TextAlign = value;}<br />
}<br />
<br />
<br />
public string Key<br />
{<br />
get { return mKey;}<br />
set { mKey = value;}<br />
}<br />
<br />
<br />
#endregion<br />
<br />
<br />
#region Events<br />
public event EventHandler ToolbarClick;<br />
<br />
protected void OnToolbarClick(EventArgs e)<br />
{<br />
if(ToolbarClick != null)<br />
{<br />
ToolbarClick(this, e);<br />
}<br />
}<br />
<br />
<br />
public event EventHandler ButtonClick;<br />
<br />
protected void OnButtonClick(EventArgs e)<br />
{<br />
if(ButtonClick != null)<br />
{<br />
ButtonClick(this, e);<br />
}<br />
}<br />
<br />
#endregion<br />
<br />
<br />
<br />
public tbToolbar()<br />
{<br />
InitializeComponent();<br />
DisplayButtons();<br />
<br />
}<br />
<br />
<br />
protected override void Dispose( bool disposing )<br />
{<br />
if( disposing )<br />
{<br />
if( components != null )<br />
components.Dispose();<br />
}<br />
base.Dispose( disposing );<br />
}<br />
<br />
#region Component Designer generated code<br />
private void InitializeComponent()<br />
{<br />
System.Resources.ResourceManager resources = new System.Resources.ResourceManager(typeof(tbToolbar));<br />
this.cmdToolbar = new System.Windows.Forms.Button();<br />
this.pnlPanel = new System.Windows.Forms.Panel();<br />
this.hbDefault = new HoverButton.hbHoverButton();<br />
this.pnlPanel.SuspendLayout();<br />
this.SuspendLayout();<br />
this.cmdToolbar.BackColor = System.Drawing.SystemColors.Control;<br />
this.cmdToolbar.Dock = System.Windows.Forms.DockStyle.Top;<br />
this.cmdToolbar.Location = new System.Drawing.Point(0, 0);<br />
this.cmdToolbar.Name = "cmdToolbar";<br />
this.cmdToolbar.Size = new System.Drawing.Size(119, 28);<br />
this.cmdToolbar.TabIndex = 0;<br />
this.cmdToolbar.Text = "Toolbar";<br />
this.cmdToolbar.Click += new System.EventHandler(this.cmdToolbar_Click);<br />
this.pnlPanel.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) <br />
| System.Windows.Forms.AnchorStyles.Left) <br />
| System.Windows.Forms.AnchorStyles.Right)));<br />
this.pnlPanel.AutoScroll = true;<br />
this.pnlPanel.Controls.Add(this.hbDefault);<br />
this.pnlPanel.Location = new System.Drawing.Point(0, 29);<br />
this.pnlPanel.Name = "pnlPanel";<br />
this.pnlPanel.Size = new System.Drawing.Size(119, 344);<br />
this.pnlPanel.TabIndex = 2;<br />
this.hbDefault.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) <br />
| System.Windows.Forms.AnchorStyles.Right)));<br />
this.hbDefault.BackColor = System.Drawing.Color.FromArgb(((System.Byte)(33)), ((System.Byte)(86)), ((System.Byte)(152)));<br />
this.hbDefault.ButtonBackColour = System.Drawing.Color.FromArgb(((System.Byte)(33)), ((System.Byte)(86)), ((System.Byte)(152)));<br />
this.hbDefault.ButtonBorderSize = 2;<br />
this.hbDefault.ButtonImage = ((System.Drawing.Image)(resources.GetObject("hbDefault.ButtonImage")));<br />
this.hbDefault.ButtonImageAlign = System.Drawing.ContentAlignment.TopCenter;<br />
this.hbDefault.ButtonText = "hoverButton";<br />
this.hbDefault.ButtonTextAlign = System.Drawing.ContentAlignment.BottomCenter;<br />
this.hbDefault.ClickedBackColour = System.Drawing.Color.FromArgb(((System.Byte)(67)), ((System.Byte)(133)), ((System.Byte)(214)));<br />
this.hbDefault.ClickedBorderColour = System.Drawing.Color.FromArgb(((System.Byte)(40)), ((System.Byte)(104)), ((System.Byte)(183)));<br />
this.hbDefault.ForeColor = System.Drawing.Color.White;<br />
this.hbDefault.HoverBackColour = System.Drawing.Color.FromArgb(((System.Byte)(40)), ((System.Byte)(104)), ((System.Byte)(183)));<br />
this.hbDefault.HoverBorderColour = System.Drawing.Color.FromArgb(((System.Byte)(67)), ((System.Byte)(133)), ((System.Byte)(214)));<br />
this.hbDefault.Location = new System.Drawing.Point(7, 2);<br />
this.hbDefault.Name = "hbDefault";<br />
this.hbDefault.Size = new System.Drawing.Size(104, 54);<br />
this.hbDefault.TabIndex = 0;<br />
this.hbDefault.Visible = false;<br />
this.BackColor = System.Drawing.Color.FromArgb(((System.Byte)(33)), ((System.Byte)(86)), ((System.Byte)(152)));<br />
this.Controls.Add(this.pnlPanel);<br />
this.Controls.Add(this.cmdToolbar);<br />
this.Font = new System.Drawing.Font("Tahoma", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((System.Byte)(0)));<br />
this.ImeMode = System.Windows.Forms.ImeMode.NoControl;<br />
this.Name = "tbToolbar";<br />
this.Size = new System.Drawing.Size(119, 372);<br />
this.Load += new System.EventHandler(this.tbToolbar_Load);<br />
this.pnlPanel.ResumeLayout(false);<br />
this.ResumeLayout(false);<br />
<br />
}<br />
#endregion<br />
<br />
<br />
public void AddButton(string strName, Image imgImage)<br />
{<br />
HoverButton.hbHoverButton tbNewButton = new HoverButton.hbHoverButton();<br />
<br />
tbNewButton.ButtonText = strName;<br />
tbNewButton.ButtonImage = imgImage;<br />
tbNewButton.Left = hbDefault.Left;<br />
tbNewButton.Width = pnlPanel.Width - 11;<br />
tbNewButton.ForeColor = Color.White;<br />
tbNewButton.Anchor = hbDefault.Anchor;<br />
tbNewButton.Visible = true;<br />
tbNewButton.Click += new EventHandler(HoverButton_Clicked);<br />
<br />
alButtons.Add(tbNewButton);<br />
<br />
DisplayButtons();<br />
}<br />
<br />
<br />
public void RemoveButton(int intIndex)<br />
{<br />
HoverButton.hbHoverButton btnTemp = (HoverButton.hbHoverButton)alButtons[intIndex];<br />
alButtons.Remove(btnTemp);<br />
<br />
DisplayButtons();<br />
}<br />
<br />
<br />
private void DisplayButtons()<br />
{<br />
<br />
pnlPanel.Controls.Clear();<br />
<br />
<br />
for(int i =0; i < alButtons.Count; i++)<br />
{ <br />
HoverButton.hbHoverButton btnTemp = (HoverButton.hbHoverButton)alButtons[i];<br />
<br />
btnTemp.Top = (mButtonHeight * (i)) + 6;<br />
btnTemp.Height = mButtonHeight;<br />
btnTemp.ButtonImageAlign = mButtonImageAlign;<br />
btnTemp.ButtonTextAlign = mButtonTextAlign;<br />
<br />
this.pnlPanel.Controls.Add(btnTemp);<br />
}<br />
}<br />
<br />
<br />
private void cmdToolbar_Click(object sender, System.EventArgs e)<br />
{<br />
OnToolbarClick(e);<br />
}<br />
<br />
<br />
private void HoverButton_Clicked(object sender, EventArgs e)<br />
{<br />
OnButtonClick(e);<br />
}<br />
<br />
<br />
private void tbToolbar_Load(object sender, System.EventArgs e)<br />
{<br />
DisplayButtons();<br />
}<br />
<br />
<br />
public HoverButton.hbHoverButton Button(int intIndex)<br />
{<br />
if((intIndex+1) > alButtons.Count)<br />
{<br />
return null;<br />
}<br />
else<br />
{<br />
HoverButton.hbHoverButton tbButton = (HoverButton.hbHoverButton)alButtons[intIndex];<br />
return tbButton;<br />
}<br />
}<br />
}<br />
<br />
<br />
public class clsHoverButtonProp<br />
{<br />
<br />
private string mButtonText = "";<br />
private System.Drawing.Image mButtonImage;<br />
<br />
<br />
public string ButtonText<br />
{<br />
get { return mButtonText;}<br />
set { mButtonText = value;}<br />
}<br />
<br />
public System.Drawing.Image ButtonImage<br />
{<br />
get{ return mButtonImage;}<br />
set{ mButtonImage = value;}<br />
}<br />
<br />
public clsHoverButtonProp()<br />
{<br />
}<br />
<br />
}<br />
}<br />
|
|
|
|
|
I am working on creating a windows service. Here I have to watch a folder for any file that is placed in that folder. If a file is placed in that folder i have to process it. I am doing this with the filesystemwatcher component's created method. This works fine when i am placing files one by one. But when i place 5 or 6 files at the same time, or when i place a file of bigger size, say above 3 MB, it produces error, saying that the an system.ioexception has occurred. The file is being used by another application. I think this is due to the fact that the windows takes some time to copy that file to that folder, whereas filesystemwatcher components starts it's execution as soon as it finds a file in that folder.
Any suggestion will be very welcome
|
|
|
|