Ramy Mahrous 401 Postaholic Featured Poster
Ramy Mahrous 401 Postaholic Featured Poster
//Global Variables
Form frmChild;

private void button1_Click(....)
{
//show child form
frmChild=new Form();
frmChild.MDIParent=this;
frmChild.Show();
frmChild.FormClosed+=new FormClosedEventHandler(frmChild_FormClosed);
//disable your button
button1.Enabled = false;
}

void frmChild_FormClosed(object sender, EventArgs e)
{
button1.Enabled = true;
}
Ramy Mahrous 401 Postaholic Featured Poster

Please clarify, where the button is? Parent Form or the Child one? and tell me the exact scenario.

Ramy Mahrous 401 Postaholic Featured Poster

So, you have Child Form which opens from the button... you'll implement the event Form Closed of the Child Form to execute this piece of code

yourButton.Enabled = true;
Ramy Mahrous 401 Postaholic Featured Poster

Work with MemoryStream it may help to separate your operations and the physical file.

Ramy Mahrous 401 Postaholic Featured Poster

Reasonable! :) should have typical copy on temp folder and work on it, if your operation successed then you delete the original one.

Ramy Mahrous 401 Postaholic Featured Poster
System.IO.File.Delete(FilePath);
Ramy Mahrous 401 Postaholic Featured Poster

Handle Keypressed event of the textbox

private void textBox1_KeyPress(object sender, KeyPressEventArgs e)
        {
            char lastChar = e.KeyChar;
            //MessageBox.Show(((int)e.KeyChar).ToString());
            if (e.KeyChar != 32 && e.KeyChar !=8) //allows space and backspace
            {
                if (char.IsControl(lastChar) || char.IsDigit(lastChar) || char.IsNumber(lastChar) || char.IsPunctuation(lastChar))
                    e.Handled = true;
                else if (lastChar < 1575)//the start of ascii codes for Arabic chars.
                    e.Handled = true;
            }
        }
Ramy Mahrous 401 Postaholic Featured Poster

Paul... I didn't get where you stuck.. but if you need tutorial guide I recommend this http://functionx.com/adonet/index.htm

Ramy Mahrous 401 Postaholic Featured Poster

What type of database are you using?

Thread name SQL in C# :)

Ketsuekiame commented: Unconstructive. There are many types of SQL driven databases. +0
kvprajapati commented: N/A +10
Ramy Mahrous 401 Postaholic Featured Poster

Trust me, it works :) please mark it as solved.

Ramy Mahrous 401 Postaholic Featured Poster

Post what you don't understand...

Ramy Mahrous 401 Postaholic Featured Poster
Ramy Mahrous 401 Postaholic Featured Poster

Copy the code!! or make it reusable control and drag it and drop it wherever.

Ramy Mahrous 401 Postaholic Featured Poster

Because of spaces man...

public void WriteDataToFile(MeetingEntry currentEntry)
        {
            OleDbConnection dbConnection = new OleDbConnection(CONNECTION_STRING);
            
            string commandString =
            "INSERT INTO MeetingEntries (Subject, Location, [Start Date], [End Date], [Enable Alarm], [Repeat Alarm], Reminder, [Repetition Type])" + " VALUES (@Subject, @Location, @StartDate, @EndDate, @EnableAlarm, @RepeatAlarm, @Reminder, @RepetitionType)";
            //"INSERT INTO MEETINGENTRIES (SUBJECT, LOCATION, START DATE, END DATE, ENABLE ALARM, REPEAT ALARM, REMINDER, REPETITION TYPE)" + " VALUES (?, ?, ?, ?, ?, ?, ?, ?)";
            
            OleDbCommand commandStatement = new OleDbCommand(commandString, dbConnection);
           

            commandStatement.Parameters.Add("Subject", OleDbType.VarWChar, 30).Value = currentEntry.Subject;
            commandStatement.Parameters.Add("Location", OleDbType.VarWChar, 50).Value = currentEntry.Location;
            commandStatement.Parameters.Add("StartDate", OleDbType.Date, 40).Value = currentEntry.StartDateTime.Date;
            commandStatement.Parameters.Add("EndDate", OleDbType.Date, 40).Value = currentEntry.EndDateTime.Date;
            commandStatement.Parameters.Add("EnableAlarm", OleDbType.Boolean, 1).Value = currentEntry.IsAlarmEnabled;
            commandStatement.Parameters.Add("RepeatAlarm", OleDbType.Boolean, 1).Value = currentEntry.IsAlarmRepeated;
            commandStatement.Parameters.Add("Reminder", OleDbType.Integer, 2).Value = currentEntry.Reminder;
            commandStatement.Parameters.Add("RepetitionType", OleDbType.VarWChar, 10).Value = currentEntry.Repetition.ToString();
            
            
            dbConnection.Open();
            commandStatement.CommandText = commandString;
            commandStatement.ExecuteNonQuery();
        }
Ramy Mahrous 401 Postaholic Featured Poster

please clarify or tell us the scenario...

Ramy Mahrous 401 Postaholic Featured Poster

From program.cs

/// <summary>
        /// The main entry point for the application.
        /// </summary>
        [STAThread]
        static void Main()
        {
            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);
            Application.Run(new Form1());//the name of the form :)      
}

Application.Run(new Form1());

Ramy Mahrous 401 Postaholic Featured Poster

So please attach here your application with the database, so I can help you better

Ramy Mahrous 401 Postaholic Featured Poster

It means the query run on Access database "INSERT INTO MeetingEntries (Subject, Location, Start Date, End Date, Enable Alarm, Repeat Alarm, Reminder, Repetition Type) VALUES (?, ?, ?, ?, ?, ?, ?, ?)" which is wrong!

Ramy Mahrous 401 Postaholic Featured Poster
foreach(Control c in tableLayoutPanel1.Controls)
{
if( c is TextBox)
c.Text = null;
else if (c is CheckBox)
c.Checked = false;
else
//.....
}
Ramy Mahrous 401 Postaholic Featured Poster

Man! please read what I posted please commandStatement.CommandText in debug mode will show you the command gonna be executed! take it copy and paste in access and run it.

Ramy Mahrous 401 Postaholic Featured Poster

Please before commandStatement.ExecuteNonQuery(); get the commandStatement.CommandText and execute the query into access. see if it runs or not.

Ramy Mahrous 401 Postaholic Featured Poster

Can you please show us the exception?

or try currentEntry.EndDateTime.Date.ToShortDateString();

Ramy Mahrous 401 Postaholic Featured Poster

What do you mean by Clear the table layout? to reset all controls value i.e all textboxs Text property = null or to set the visibility = false
You can access all TableLayoutPanel controls by tableLayoutPanel1.Controls

Ramy Mahrous 401 Postaholic Featured Poster

To solve it and I assume taxableIncome is TextBox or Label

taxableIncome.Text = Convert.ToDouble(userValueTB.Text).ToString();
Ramy Mahrous 401 Postaholic Featured Poster

What's taxableIncome? please use code tags!
To solve second error

taxLBL.Text = Convert.ToDouble(taxLBL.Text).ToString();
Ramy Mahrous 401 Postaholic Featured Poster

Use AddRange method instead

ListBox2.Items.AddRange(ListBox1.Items);
kvprajapati commented: Solved! +9
Ramy Mahrous 401 Postaholic Featured Poster

If you're newbie.. please read in generics, arrays, and files
Generics http://msdn.microsoft.com/en-us/library/512aeb7t(VS.80).aspx
Arrays http://msdn.microsoft.com/en-us/library/aa288453(VS.71).aspx
File http://msdn.microsoft.com/en-us/library/system.io.file(VS.80).aspx

Ramy Mahrous 401 Postaholic Featured Poster
Ramy Mahrous 401 Postaholic Featured Poster

use generics...

List<string> personsData = new List<string>();
string personData = "name,phone,number,postcode";
personsData.Add(personData);
//use System.IO.File class to store personsData content...
Ramy Mahrous 401 Postaholic Featured Poster

Zizi, please take a look on the examples above the code...
First Parameter the string, second one the set, and third you tell the method select to not show first\second\etc.. string from the set..

Ramy Mahrous 401 Postaholic Featured Poster

That's great :) I develop small method do that work you may use Regular Expression but I prefered to write my code...

MessageBox.Show(Zizi("aABD", new string[]{"A", "B"}, 0)); // No A
MessageBox.Show(Zizi("aABD", new string[] { "A", "B" }, 1)); // No B
MessageBox.Show(Zizi("aABD", new string[] { "A", "B" }, 0,1)); //No A nor B
MessageBox.Show(Zizi("aABD", new string[] { "A", "B" }, 2)); //A and B

 private string Zizi(string str, string[] set, params int[] whatToNotCome)
        {
            string output = str;
            for (int i = 0; i < set.Length; i++)
            {
                if (whatToNotCome.Contains(i))
                    output = output.Replace(set[i], null); 
            }
            return output;
        }

Got the idea or I should explain my code...?

kvprajapati commented: Working!!! +9
Ramy Mahrous 401 Postaholic Featured Poster

I don't get your rule! can you please guide me with more examples to recognize its pattern

Ramy Mahrous 401 Postaholic Featured Poster

To be aligned I'll illustrate what I got you mean you want to get distinct characters from string into array
Ex.
Input: RAMY MAHROUS
Output: {R A M Y H O U S}
correct?

Ramy Mahrous 401 Postaholic Featured Poster

Let's start it over...

string fileData = File.ReadAllText(@"file path");
checkedListBox1.Items.AddRange(fileData.Split(new string[] { "\r\n" }, StringSplitOptions.RemoveEmptyEntries));
Ramy Mahrous 401 Postaholic Featured Poster

Debug, because I'm pretty sure it don't enter "if" block //no condition
because DialogResult.No should be DialogResult.Cancel
Please try it..

Ramy Mahrous 401 Postaholic Featured Poster
Ramy Mahrous 401 Postaholic Featured Poster

Something I begun to note is most of askers ignore my reply... and even don't comment, what does it mean????!!!
@papanyquiL didn't you see my reply?? or I should clarify?? or you aren't satisfied with the code??

Ramy Mahrous 401 Postaholic Featured Poster

This piece of code enumerate on the local drives then gets it root path then search for every exe on you can use SystemFileInfo to handle nested directories...

foreach (System.IO.DriveInfo dirveInfo in System.IO.DriveInfo.GetDrives())
            {
                foreach(System.IO.FileInfo fileInfo in dirveInfo.RootDirectory.GetFiles("*.exe"))
                    ///add the exe in list or handle it as you like
            }
Ramy Mahrous 401 Postaholic Featured Poster

I learnt a lot from this threadm thanks thanks thanks

Ramy Mahrous 401 Postaholic Featured Poster

File | You may use Move method in System.IO like that

System.IO.File.Move(@"C:\old.txt", @"C:\new.txt"); //it renames the file old to new.txt

Folder | the same

System.IO.Directory.Move(@"C:\oldfolder", @"C:\newfolder");
Ramy Mahrous 401 Postaholic Featured Poster

So please send your class code you want to group and order it; the class has this struct to play with this problem.

Ramy Mahrous 401 Postaholic Featured Poster

Why ArrayList?! Are you fond of casting??
Use generics List<Photo> photos = new List<Photo>(); and in Photo class you may have list of photos and indexer to get them by index or name anything is unique..

sknake commented: agreed +14
Ramy Mahrous 401 Postaholic Featured Poster

On the ComboBox double click, VS created a handler for index changed event copy and paste your code, and solve any error if exists..

Ramy Mahrous 401 Postaholic Featured Poster
var col = from le in mylist
group le by le.X into g         
orderby g.Key descending
select g;

On two phases

var colGrouped = from le in mylist
group le by le.X select le;

var colOrdered = from colGrouped ..... orderby...
kvprajapati commented: Excellent. +16
jonsca commented: Some long overdue rep +1
Ramy Mahrous 401 Postaholic Featured Poster

LOL! did you read my reply??!!

There's events detect that
TextBox | TextChanged
ComboBox | SelectedIndexChanged

Ramy Mahrous 401 Postaholic Featured Poster

I see it's very simple in design and this is good, if it does its functionality well so you don't over care about its design.

Nice work, Diamonddrake

Ramy Mahrous 401 Postaholic Featured Poster

You just need to close the code tag.
You should have another property holding image file path

public string ImageFilePath
{
get...
set....
}
public Image Imge
{
get
{
try
{
return _Imge;
}
catch
{
Bitmap bm = new Bitmap(100, 100);
Graphics g = Graphics.FromImage(bm);
g.Clear(Color.WhiteSmoke);
Pen p = new Pen(Color.Red, 5);
g.DrawLine(p, 0, 0, 100, 100);
g.DrawLine(p, 100, 0, 0, 100);
return bm;
}
}
set {
using (Image _Imge = Image.FromFile(ImageFilePath))
Imge = value;
}
}

Set the ImageFilePath first...

Ramy Mahrous 401 Postaholic Featured Poster

Try to group first then order second

Ramy Mahrous 401 Postaholic Featured Poster

There's events detect that
TextBox | TextChanged
ComboBox | SelectedIndexChanged