|
Hello Muammar,
You need to cut down on Coca Cola, mate! Those stuff seems to get you far too hyper.
If I am not mistaken this is a Message Board and people are Free to ask question as long as they don't get too sexual or emotional. Lucky for people like me who are learning and not afraid of asking; there are knowledgeable and kind people, unlike you, whom are happy to take a moment and teach.
I guess that explains why some of my teachers sucked and some others were exceptional and made a long lasting impression.
Any ways, just stay way from Coca Cola and I am sure everything is going to work out just fine, mate.
Have a great weekend.
Khoramdin
Ps. There is a movie called "Pay it forward". I suggest you to rent and watch it.
|
|
|
|
|
.. I hope you found what you're looking for though!
Smile: A curve that can set a lot of things straight!
(\ /)
(O.o)
(><)
|
|
|
|
|
Hello Muammar©,
I am sure I will, mate. Just don't let little things gets into you.
By the way, can you be more specific with your question about Camera pix. I think I have the answer to your question. Just would like to be sure I can give you what it is you are looking for, mate.
Have a great weekend.
Khoramdin
|
|
|
|
|
Khoramdin wrote: I am sure I will
Good!
Khoramdin wrote: about Camera pix
oh, thanks, but don't worry, I think I found something.
Have a nice weekend too.
Smile: A curve that can set a lot of things straight!
(\ /)
(O.o)
(><)
|
|
|
|
|
Use FileMode.Append .
"Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the Universe trying to produce bigger and better idiots. So far, the Universe is winning." - Rick Cook www.troschuetz.de
|
|
|
|
|
Hello Stefan,
Thanx for the help. you are correct. That was the problem and I am very greatful for your help.
have a great weekend.
Khoramdin
|
|
|
|
|
Have you thought about using StreamWriter instead of FileStream ?
Although similar results can be achieved with both, It is specifically designed for writing text into streams.
See this: http://msdn2.microsoft.com/en-us/library/system.io.streamwriter.aspx
Following your example, the code would be something like:
StreamWriter sw = File.AppendText( FileName );
sw.WriteLine( "{0},{1}", userName, userSureName );
sw.Close();
The above code would append or create the file if it didn't already exist.
Does this help?
Regards
Wayne Phipps
____________
Time is the greatest teacher... unfortunately, it kills all of its students
View my Blog
|
|
|
|
|
Hello Wayne,
Thanx so taking the time and help, mate. I tried your suggestion and it work.
I am very greatful for the help.
Have a great weekend.
Khoramdin
|
|
|
|
|
iam working in c#2005 desktop application
i have data grid that fill with data one column is date column when i click the row it's fill comboboxs and textboxs with selected row data i need to take the date from date column and change the date in datetimepicker
i write that code but it generate error why
**********************************************************
dateTimePicker1.Value = Convert.ToDateTime(dataGridView1[2,rowno].Value.ToString());
***********************************************************
ma_refay
|
|
|
|
|
ma_refay wrote: i write that code but it generate error why
What error?
By the way, what do you mean by date column; do you store string representations of dates or DateTime objects. In case of the latter you could directly assign them to the DateTimePicker without turning them into a string representation and then reparsing to a DateTime object.
"Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the Universe trying to produce bigger and better idiots. So far, the Universe is winning." - Rick Cook www.troschuetz.de
|
|
|
|
|
Hi,
I'm a newbie and am working on this project for about a week now. I need to create a Dog class where the user will be able to interact with the class using "Pet (dog not angry), Tease(dog angry), Feed(dog not hungry), Age(dog hungry), GoToSleep(dog asleep) and WakeUp(dog not asleep).
This is the code in my Dog class
[CODE]
class Dog
{
private bool isHungry;
private bool isAngry;
private bool isSleeping;
public bool IsHungry
{
get
{
return isHungry;
}
}
public bool IsAngry
{
get
{
return isAngry;
}
}
public bool IsSleeping
{
get
{
return isSleeping;
}
}
public Dog()
{
isHungry = false;
isAngry = false;
isSleeping = false;
}
public void Pet()
{
isAngry = false;
}
public void Tease()
{
isAngry = false;
}
public void Feed()
{
isHungry = false;
}
public void Age()
{
isHungry = true;
}
public void GoToSleep()
{
isSleeping = true;
}
public void WakeUp()
{
isSleeping = false;
}
}
[/CODE]
I created buttons.
[CODE]
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
public void pictureBox1_Click(object sender, EventArgs e)
{
}
public void buttonPet_Click(object sender, EventArgs e)
{
}
public void buttonTease_Click(object sender, EventArgs e)
{
}
public void buttonFeed_Click(object sender, EventArgs e)
{
}
public void buttonAge_Click(object sender, EventArgs e)
{
}
public void buttonGoToSleep_Click(object sender, EventArgs e)
{
}
public void buttonWakeUp_Click(object sender, EventArgs e)
{
}
}
[/CODE]
I have placed images of dogs in an image list but don't know how to proceed from here. How do I get the button to do what it is supposed to do and show an image? The images are as follows:
angry_dog.bmp
eat_dog.gif
happy_dog.jpg
sleep_dog.jpg
I also wrote the following code but have no clue where to put it. Right now it is in Program.cs under main.
[CODE]
Dog myDog;
myDog = new Dog();
myDog.Pet();
myDog.Tease();
myDog.Feed();
myDog.Age();
myDog.GoToSleep();
myDog.WakeUp();
[/CODE]
Please help.
|
|
|
|
|
apricotsun wrote: public void buttonGoToSleep_Click(object sender, EventArgs e)
{
}
This is an event handler. Assuming that myDog is a member variable ( declared inside a class, not inside any method, and therefore visible to all methods for this instance of this class ), you should do myDog.GoToSleep(); here. I trust you can see how this pattern would apply to your other methods/events.
apricotsun wrote: I have placed images of dogs in an image list but don't know how to proceed from here.
There are a number of controls that will show an image from an image list, they will take the image list and an index into the list. So, if you use such a control, you can just change the index in the control that shows the image, inside those event handlers.
An alternative is to add the images to your resources, and load them from there. Then you can just use a PictureBox and keep changing what image it shows.
Christian Graus - Microsoft MVP - C++
Metal Musings - Rex and my new metal blog
"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 )
|
|
|
|
|
Thank you. I will try that.
|
|
|
|
|
Picture box sounds like a great idea. How do I get it to change images when the appropriate button is clicked on?
|
|
|
|
|
Also, where do I declare myDog? I tried declaring it in the Dog class but that did not work. Then I tried declaring it under Main in the Program.cs but that did not work. Then I tried declaring it in the form itself and that did not work. Would I have to create another class for it? I'm sorry for asking so many questions. As I said I'm a newbie and want to learn.
|
|
|
|
|
I am confused. I want Windows to act like this: When the user double clicks the icon in Windows Explorer, it opens up the file my program opens with my program. But how do I set up my program so that this will happen? Thanks in advance.
|
|
|
|
|
C# does Shell, Part 2[^]
"Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the Universe trying to produce bigger and better idiots. So far, the Universe is winning." - Rick Cook www.troschuetz.de
|
|
|
|
|
I am trying to add a tool bar using ToolStrip. When I run my application, the tool bar is correctly display, but once I get an OnPaint, I get red box with an X through it where the tool bar should reside. Here is my code.
ToolStrip toolStrip = new ToolStrip();
toolStrip.Parent = this;
ToolStripButton toolStripFileOpen = new ToolStripButton("Open", new Bitmap("openHS.png"), new EventHandler(MenuFileOpenOnClick), "Open");
ToolStripButton toolStripFileSave = new ToolStripButton("Save", new Bitmap("saveHS.png"), new EventHandler(MenuFileSaveOnClick), "Save");
toolStripFileOpen.DisplayStyle = ToolStripItemDisplayStyle.Image;
toolStripFileSave.DisplayStyle = ToolStripItemDisplayStyle.Image;
ToolStripSeparator toolStripSeparator = new ToolStripSeparator();
toolStrip.Items.Add(toolStripFileOpen);
toolStrip.Items.Add(toolStripFileSave);
toolStrip.Items.Add(toolStripSeparator);
Controls.Add(toolStrip);
|
|
|
|
|
Sounds like when you run it, it cannot file those png files. I'd suggest making them resources inside your program, or at least, copy them to the debug/release directories.
Christian Graus - Microsoft MVP - C++
Metal Musings - Rex and my new metal blog
"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 )
|
|
|
|
|
The png files belonged to the project and were made an "Embedded Resource" so I don't think that is the problem. The funny thing is they are displayed fine until I get an OnPaint. I am missing something but I can't find a good reference on ToolStrip.
|
|
|
|
|
Here is an update. I used the auto stuff in .NET for making a form and got the same results. It seems the OnPaint for the client area is being called for the ToolStrip. I just assumed ToolStrip would have it's on OnPaint method.
Here is my entire constructor. I am a fairly new to the C# stuff and this is my learning program. I did not want to use the auto stuff in .NET until I made an application by "hand".
public GLA()
{
Text = "GLA";
programName = Text;
BackColor = SystemColors.Window;
ForeColor = SystemColors.WindowText;
ResizeRedraw = true;
Icon = new Icon(GetType(), "GLA.ico");
// Status bar.
statusBarPanel = new StatusBarPanel();
statusBarPanel.AutoSize = StatusBarPanelAutoSize.Contents;
statusBar = new StatusBar();
statusBar.Parent = this;
statusBar.ShowPanels = true;
statusBar.Panels.Add(statusBarPanel);
// Tool bar.
ToolStrip toolStrip = new ToolStrip();
ToolStripButton toolStripFileOpen = new ToolStripButton("Open", new Bitmap("openHS.png"), new EventHandler(MenuFileOpenOnClick), "Open");
ToolStripButton toolStripFileSave = new ToolStripButton("Save", new Bitmap("saveHS.png"), new EventHandler(MenuFileSaveOnClick), "Save");
toolStripFileOpen.DisplayStyle = ToolStripItemDisplayStyle.Image;
toolStripFileSave.DisplayStyle = ToolStripItemDisplayStyle.Image;
ToolStripSeparator toolStripSeparator = new ToolStripSeparator();
toolStrip.Items.Add(toolStripFileOpen);
toolStrip.Items.Add(toolStripFileSave);
toolStrip.Items.Add(toolStripSeparator);
Controls.Add(toolStrip);
// Menus.
menu = new MenuStrip();
menuFile = new ToolStripMenuItem("&File" );
menuFileOpen = new ToolStripMenuItem("&Open..." , new Bitmap("openHS.png"), new EventHandler(MenuFileOpenOnClick ), Keys.Control | Keys.O);
menuFileSave = new ToolStripMenuItem("&Save" , new Bitmap("saveHS.png"), new EventHandler(MenuFileSaveOnClick ), Keys.Control | Keys.S);
menuFileSaveAs = new ToolStripMenuItem("Sa&ve As..." , null , new EventHandler(MenuFileSaveAsOnClick), Keys.Control | Keys.V);
menuFileExit = new ToolStripMenuItem("&Exit" , null , new EventHandler(MenuFileExitOnClick ), Keys.Control | Keys.E);
menuHelp = new ToolStripMenuItem("&Help" );
menuHelpAbout = new ToolStripMenuItem("&About" , new Bitmap("GLA.ico" ), new EventHandler(MenuHelpAboutOnClick ), Keys.Control | Keys.A);
menuSeparator = new ToolStripSeparator();
menuFileOpen .AutoToolTip = true; menuFileOpen .ToolTipText = "Open a file to edit or view" ;
menuFileSave .AutoToolTip = true; menuFileSave .ToolTipText = "Save the current data set" ;
menuFileSaveAs.AutoToolTip = true; menuFileSaveAs.ToolTipText = "Save data set with a different name";
menuFileExit .AutoToolTip = true; menuFileExit .ToolTipText = "Exit the program" ;
// Add items to the main menu.
menu.Items.Add(menuFile);
menuFile.DropDownItems.Add(menuFileOpen );
menuFile.DropDownItems.Add(menuFileSave );
menuFile.DropDownItems.Add(menuFileSaveAs);
menuFile.DropDownItems.Add(menuSeparator );
menuFile.DropDownItems.Add(menuFileExit );
menu.Items.Add(menuHelp);
menuHelp.DropDownItems.Add(menuHelpAbout );
// Add the list of controls.
Controls.Add(menu);
// Assign the menu to the form.
MainMenuStrip = menu;
// Disable Save and SaveAs since there is no file open.
menuFileSave .Enabled = false;
menuFileSaveAs.Enabled = false;
}
|
|
|
|
|
I have determined the application is using the ToolStrip area as the client area. ToolStrip is calling my OnPaint, OnMouseDown, etc. for the ToolStrip. How do I force it not to do this?
|
|
|
|
|
After going back in Petzold's book, he states that overriding OnPaint also overrides the Controls (ToolStrip, etc.). I read that if one calls Invalidate(false), the child controls will not get the message. Anyway, I made the client area a Panel and made event handlers for mouse moves, paint, etc. This was actually easier to paint to because now I do not have to determine the offsets for the tool bar, status bar, and menu.
Now I need to find an example for StatusStrip instead of using StatusBar.
|
|
|
|
|
Christian, thanks for the advise. If I already have the png files, how to I add the png files as a resource so they are included in the executable? Also, how do I load them into the application?
|
|
|
|
|
Simple question but I guess no one knows the answer.
I finally figured it out.
1) Add a bmp, ico, etc. to your project.
2) Select properties on bmp, ico, etc. and make Build Action - Embedded Resourse
3) Select properties on project, and make Default namespace: - Tools.Test
4) If the code in not in a namespace, then you can loose the Tools prefix.
using System;
using System.Drawing;
using System.Windows.Forms;
namespace Tools
{
class Test : Form
{
public static void Main()
{
Application.Run(new Test());
}
public Test()
{
Text = "Test";
Icon = new Icon(GetType(), "Test.Test.ico");
}
}
}
|
|
|
|
|