Ramy Mahrous 401 Postaholic Featured Poster

First solution came is to group them inside UserControl, and play with them like above.

Ramy Mahrous 401 Postaholic Featured Poster
ddanbe commented: Good tip Ramy :) +7
Ramy Mahrous 401 Postaholic Featured Poster

1- Handler TextBox Key pressed event handler.

ddanbe commented: Hi Ramy! Nice snippet :) +6
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

I got yesterday a question how to get average date from list of dates, and here's my answer.

kvprajapati commented: definitely, sum of ticks. +10
Ramy Mahrous 401 Postaholic Featured Poster

Create table for recipe (name, description, avg. time to do it, how to make it etc..)
Create table form ingredients (name, etc..)
Create bridge table for both tables (DB concepts)
It's almost done!
Make a program to connect to this database search on (recipe name or recipe description) and show how to make it and some light logic.

You should thank your mom because she'll make you learn something new.

Ramy Mahrous 401 Postaholic Featured Poster

I don't like the sign... It should be visible by default not just when I over my mouse on someone profile picture!

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

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 searched for this error I got this link http://msdn.microsoft.com/en-us/library/95scxcdy(VS.80).aspx try it

kvprajapati commented: Welcome back! +9
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

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
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

In terms of long lists and performance, Danny's solution is the best and to make it better use 'for' loop instead of 'foreach'
My test on 10000 items
Danny (for not foreach) | 39060 ticks
Danny | 48825 ticks
adatapost | 761670 ticks

kvprajapati commented: Test++ +15
ddanbe commented: Nice you did this test! +13
Ramy Mahrous 401 Postaholic Featured Poster

I've question when it loses its format? try to catch the message returned from xml webservice and see if it comes in the right format or not? I just want to put my hand on the phase content loses its format.

serkan sendur commented: welcome back +8
sknake commented: welcome back! +14
Ramy Mahrous 401 Postaholic Featured Poster

Here's I wrote some code to move controls on the form
1- Assign (Control_MouseMove, Control_MouseDown, and Control_MouseUp) to the controls you need it movable.

ddanbe commented: Great! +6
Ramy Mahrous 401 Postaholic Featured Poster

Math.Add ??? Exists in Math class??! The answer shouldn't be to use it or not to use it.
Regardless this small operation in sometimes I shouldn't do that. Try we log error\exceptions
I can't permit developers team to do that

try
{
}
catch (Exception ex)
{
File.AppendAllText(ExceptionFilePath, ex.Message);
}

BUT, They must have method logs the error

try
{
}
catch (Exception ex)
{
LogException(ex);
}
void LogException(Exception ex)
{
//Today DM (Development Manager) said we should use File
//Yesterday they said we should log in database
//tomorrow I think they aren't interested to know what exceptions happened
}

Centralize operations important.

Again, regardless small adding operation mentioned above.

ddanbe commented: Keep us awake man! +7
Ramy Mahrous 401 Postaholic Featured Poster

I don't have solution else open the downgraded project on VS 2005 then add new project (Setup wizard project) there on it.

But did you answer my questions

Excuse me, how could you know it's compiling on 3.5 ? did you try to run this application on machine JUST HAS 2.0??
Installation project is 2.0 or 3.5?

mypicturefaded commented: Here is some rep! Thanks for the help today! +1
Ramy Mahrous 401 Postaholic Featured Poster
String html = richTextBox1.Text;
            List<string> matches = new List<string>();
            Regex r = new Regex("href\\s*=\\s*(?:\"(?<1>[^\"]*)\"|(?<1>\\S+))", RegexOptions.IgnoreCase | RegexOptions.Compiled);
            Match m;// = r.Match(
            for (m = r.Match(html); m.Success; m = m.NextMatch())
            {
                matches.Add(m.Value);
                MessageBox.Show(m.Value);
                //new modified code
                //newGroups.Add(m.Groups[index]); //not 1 as you say
            }
farooqaaa commented: thanks man ~ farooqaaa +2
Ramy Mahrous 401 Postaholic Featured Poster

You're welcome my friend, Danny
I Hope it solves their problem.

wingers1290 commented: Brilliant +1
Ramy Mahrous 401 Postaholic Featured Poster
foreach(Control c in Panel1.Controls)
{
if(c is TextBox)
MessageBox.Show(string.Format("TextBox Name: {0} , TextBox Text {1}",c.Name, c.Text));
}
ddanbe commented: Nice snippet! +7
Ramy Mahrous 401 Postaholic Featured Poster

No, Serkan it also used as they said in desktop application SQL Server Compact 3.5 is a free, easy-to-use embedded database engine that lets developers build robust Windows Desktop and mobile applications that run on all Windows platforms including Windows XP, Vista, Pocket PC, and Smartphone. read more

You're both right everyone has another piece of information.

Ramy Mahrous 401 Postaholic Featured Poster

@Lighthead
You're welcome.
Nothing called stupid, you're trying to help and you should be thanked.
Nice to have you around and trying to help others.

lighthead commented: Nice piece of code. +2
Ramy Mahrous 401 Postaholic Featured Poster

To get word by word then search on specific word

int GetWordIndex(string word)
{
char[] splitters = new char[]{' '};
string[] wordsArr = RichTextBox1.Text.Split(splitters, StringSplitOptions.RemoveEmptyEntries);
for(int i=0; i< wordsArr.Length; i++)
if(string.Equals(wordsArr[i], word, StringComparison.InvariantCultureIgnoreCase))
return i;
return -1; //indicates there is no match
}
sknake commented: ramy got it again! +4
Ramy Mahrous 401 Postaholic Featured Poster

How you bind your ComboBox?
Because we may wrap it by custom class and get unique items

serkan sendur commented: nice +5
Ramy Mahrous 401 Postaholic Featured Poster

@Scott, they say SQL Server 2005 not 2000, Express not MSDE, because if they need to search on some code to attach they'll be confused.

sknake commented: good catch +4
Ramy Mahrous 401 Postaholic Featured Poster
ddanbe commented: Nice reply! +7
Ramy Mahrous 401 Postaholic Featured Poster

I added some modifications to Scott code

using System;
using System.Diagnostics;
using System.IO;
using System.Windows.Forms;

namespace daniweb
{
  public partial class frmFile : Form
  {
    public frmFile()
    {
      InitializeComponent();
    }

    public static void AppendText(string FileName, string Buffer)
    {
      //I'm using another method here in case you want to log writes etc. 
      //It encapsulates the write process
      File.WriteAllText(FileName, Buffer);
    }

    private void button1_Click(object sender, EventArgs e)
    {
      const string fName = @"C:\file3.txt";
      string buffer = Guid.NewGuid().ToString(); //junk data
      AppendText(fName, buffer);
      Process p = Process.Start("notepad.exe", fName);
      p.WaitForExit();
    }
  }
}
Ramy Mahrous 401 Postaholic Featured Poster

Excuse me I've another solution :) due to being fan of SMO I'll do it using it

public void (string databaseName, string filePath)
{
try
            {
                Server localServer = new Server(); //local using windows athuentication 
                Backup backupMgr = new Backup();
                backupMgr.Devices.AddDevice(filePath, DeviceType.File);
                backupMgr.Database = databaseName;
                backupMgr.Action = BackupActionType.Database;
                backupMgr.SqlBackup(localServer);
            }
            catch(Exception ex)
            {
                MessageBox.Show(ex.Message + " " + ex.InnerException);
            }
}
sknake commented: best solution on the thread +3
Ramy Mahrous 401 Postaholic Featured Poster

I also nominate Danny (ddanbe) and adatapost, please take this issue into your consideration.

ddanbe commented: You're too kind. +7
Ramy Mahrous 401 Postaholic Featured Poster

To allow multiple selection from report parameters check Multi-value

Ramy Mahrous 401 Postaholic Featured Poster

And adatapost forgot to say check MSDN.com after welcoming you :p
C#
http://msdn.microsoft.com/en-us/vcsharp/default.aspx
SQL Server
http://msdn.microsoft.com/en-us/sqlserver/default.aspx
For windows application\WPF\WCF
http://windowsclient.net/learn/

Ramy Mahrous 401 Postaholic Featured Poster
ddanbe commented: You are too kind! +6
Ramy Mahrous 401 Postaholic Featured Poster

It depends?
If it depends on users and secure data -> Session
If it depends on users and not secure data -> Cookies
If it doesn't depend on users -> Cache or Application variables
It just hints and I may be wrong please ask questions related to asp.net in ASP.NET forum http://www.daniweb.com/forums/forum18.html

Ramy Mahrous 401 Postaholic Featured Poster

hmmm, why should I do that, we take salaries based on number of tasks we do neither number of hours nor number of lines of code :D

ddanbe commented: Could not have said it better. +6
Ramy Mahrous 401 Postaholic Featured Poster

I think you just need to change the ShowMessage() to show the .Name property instead of .Text, try this:

WHAT :) I think they should overcome this!!!

sknake commented: you would think but thats obviously not the case ;) +2
Ramy Mahrous 401 Postaholic Featured Poster

hehehehehee extraordinaryyyyyyyyyyyyyyyyyyyyyyyyyyyy

serkan sendur commented: this is an advance credit, think about it man, ten days.. +4
Ramy Mahrous 401 Postaholic Featured Poster

WorkSheet.... because you use COM, which you didn't terminate it yourself and if you open the task manager you will see Test10.exe is running. Try adatapost help it solves your problem

Ramy Mahrous 401 Postaholic Featured Poster

Yes I say it inherits from DBCommand and overrides Dispose method

sknake commented: I meant to thank you for posting about .net decompilers +2
Ramy Mahrous 401 Postaholic Featured Poster

SqlCommand doesn't implement IDisposable but DBCommand does,

SqlCommand inherits from DBCommand

ddanbe commented: Nice remark! +6
Ramy Mahrous 401 Postaholic Featured Poster

It's my pleasure really adatapost when you correct for me, thanks a lot :)

kvprajapati commented: You are industrious. +3
Ramy Mahrous 401 Postaholic Featured Poster

Very good adatapost, I forgot to open connection!

Ramy Mahrous 401 Postaholic Featured Poster

ex.InnerException and plus you didn't show the error because you are working on Windows-based application
modify your catch block to

catch (Exception ex)
{
// Display any exceptions
//Console.WriteLine(ex.Message);
MessageBox.Show(ex.Message);
MessageBox.Show(ex.InnerException);
//MessageBox.Show("Transaction Failed");
// If anything failed after the connection was opened, roll back the transaction
if (txn != null)
{
txn.Rollback();
}
}
Blaine Tuisee commented: Gave me the tool, the exception message, that allowed me to find the issue +2
Ramy Mahrous 401 Postaholic Featured Poster

No friend it's poosible.
From ComboBox properties let
AutoCompleteMode = SuggestAppend
AutoCompleteSource = ListItems

jen140 commented: Thanks for help =) +1
serkan sendur commented: very good solution +4
Ramy Mahrous 401 Postaholic Featured Poster

Your thread subject is totally different than the thread itself.
Sknake, they can't use SQL Profiler as

Consider that I dont have admin rights...

Log file is your eye, you can see through each transaction happened.

sknake commented: good catch ;) +1
Ramy Mahrous 401 Postaholic Featured Poster

I just need to answer one question and dig the other.
To handle keys pressed when your application on top or activated (any term you prefer) you need to set Form property (Key preview = true) then handle Key press event handler.

The question I want to discuss with you, what about if I want to get the keys user pressed whatever the status of my application (minimized, maximized, etc...) is answer is to override Windows API (the queue handles the key pressed as example..) I don't know actually how do I, but I'll try to develop an application and keep you up-to-date.

Ramy Mahrous 401 Postaholic Featured Poster

If you execute SQL Statement against SQLite, add distinct!! DataSet hasn't do to any much work over it carries data for you!

toadzky commented: Gave the correct solution. +3
Ramy Mahrous 401 Postaholic Featured Poster

Daniweb just shows everything 32 days ago... please check this!

Salem commented: Delete your browser cache and cookies - problem solved +29
Ramy Mahrous 401 Postaholic Featured Poster

Yes, Danny, it's Vista problem (Aero, and Vista basic) color scheme, if you turn it into Windows Classic it'd work.

Or, remove Vista style

[STAThread]
        static void Main()
        {
            //Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);
            Application.Run(new Form1());
        }
ddanbe commented: Offered a plethora of solutions to the problem! +4
Ramy Mahrous 401 Postaholic Featured Poster

So, mark this thread as solved.