Ramy Mahrous 401 Postaholic Featured Poster
currentTextBox.Text = DateTime.Today.ToShortDateString();
threeDaysTextBox.Text = DateTime.Today.Add(new TimeSpan(3, 0, 0, 0)).ToShortDateString();
Ramy Mahrous 401 Postaholic Featured Poster

hmmm, look
If you have button open in Form1 to open Form2, then you should declare Form2 as global variable in Form1 to be able to play with it.

//Form 1 class
class Form1 : Form
{
Form2 m_form2;

//Click event handler of Open button
public void OpenClick(object sender, EventArgs e)
{
m_form2 = new Form2();
m_form2.Show();
}

//Click event handler of Close button
public void CloseClick(object sender, EventArgs e)
{
//be sure it initialized
m_form2.Close();
}
}

That's it :)

Ramy Mahrous 401 Postaholic Featured Poster

If you want to close all the forms, you can write this line in the event handler of the BTNNO click event handler

Application.Exit();

But if you need to close some forms, you should declare them in the form opens them globally then call it like that formInstance.Close(); this also in the BTNNO event handler and sure this button in the form opens the rest of forms (LOOL I hope you get me right now).
I think you should reopen the forms again to be affected.

Ramy Mahrous 401 Postaholic Featured Poster

First please copy free-syntax error code

public class vehicle
        {
            public vehicle()
            {
                MessageBox.Show("I'm Vehicle");
                //do some initialization for all vehicles
            }
        }

        public class automobile : vehicle
        {
            public automobile()
            //: base()
            {
                MessageBox.Show("I'm Automobile");
                // do specific initialization for auto
            }
        }

        public class truck : automobile
        {
            public truck() //: base()
                
            {
                MessageBox.Show("I'm Truck");
                // do specific initialization for truck
            }
        }

So, you don't need Automobile construction

public class automobile : vehicle
        {
            //public automobile()
            //    //: base()
            //{
            //    MessageBox.Show("I'm Automobile");
            //    // do specific initialization for auto
            //}
        }
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

Thanks a lot for helping me......
My project is attached here.......
In this, when I executed the project,there in textbox I entered the string which is text of any of the forms made by me.
Like I entered the string "How to compare string " which is the text of Form2. But on clicking search button,its giving nothing .
Kindly solve my problem.........

I got it!!! that's appear on your computer or not?

Ramy Mahrous 401 Postaholic Featured Poster

Attach your developed application and provide us with test case, I don't think this problem needs all those replies except you all missing something and it's not so clear.

Ramy Mahrous 401 Postaholic Featured Poster

Please attach picture to what happened to understand you well.

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

Turn it into use 2.0!

Ramy Mahrous 401 Postaholic Featured Poster

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?

Ramy Mahrous 401 Postaholic Featured Poster

If you do that, you're applications supposed to run on .NET framework 2, did you do that? with all application references??

Ramy Mahrous 401 Postaholic Featured Poster

Evening, Danny :)
I didn't see your reply.

Ramy Mahrous 401 Postaholic Featured Poster

First please use Code tags.
Second, make class to handle this

class MyWord //may implement some interfaces
{
string word;
public string Word { get; set;}

int rank;
public int Rank { get; set;} 
}

Then when some search meets increase the rank.

Ramy Mahrous 401 Postaholic Featured Poster

Because you didn't take my code and just replace field1 with c, isn't it??
Surround second if with { }
Take my code copy and paste please.

private void FieldStore()
{
foreach (Control c in panel1.Controls)
{
if (c is TextBox)
if (c.Name == "field1")
{
c.Text = Area.Room1;
MessageBox.Show("This is Field1");
}
}
}
Ramy Mahrous 401 Postaholic Featured Poster

What's this line field1.Text = Area.Room1; ??
Modify it to

private void FieldStore()
           {
               foreach (Control c in panel1.Controls)
               {

                   if (c is TextBox)
                       if (c.Name == "field1")
{
                           c.Text = Area.Room1;
                           MessageBox.Show("This is Field1");
}
               }
            
           }
Ramy Mahrous 401 Postaholic Featured Poster

Please attach the project or show us the whole code which creating\searching the TextBox. and don't forget to surround it inside code tag.

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

Can you please give me the link? to know what's this about.

Ramy Mahrous 401 Postaholic Featured Poster

No.

Ramy Mahrous 401 Postaholic Featured Poster

Sure it won't work as index not defined but what I need to say is you everytime add the same Group instance which in the index 1 of the array of Group.

Ramy Mahrous 401 Postaholic Featured Poster
String html = getSource();
List<Group> newGroups = new List<Group>();
r = new Regex("class=lnk href\\s*=\\s*(?:\"(?<1>[^\"]*)\"|(?<1>\\S+))", RegexOptions.IgnoreCase | RegexOptions.Compiled);
for (m = r.Match(html); m.Success; m = m.NextMatch())
{ 
      MessageBox.Show("Link" + m.Groups[1].Value); 
//new modified code
newGroups.Add(m.Groups[index]); //not 1 as you say
}

Read my comments in the code I may got you wrong.

Ramy Mahrous 401 Postaholic Featured Poster

My mistake, modify it to
== instead of =

foreach(Control c in Panel1.Controls)
{
if(c is TextBox)
if(c.Name == "field1") //or any property c.Text == "" or c.....
MessageBox.Show(string.Format("TextBox Name: {0} , TextBox Text {1}",c.Name, c.Text));
}
Ramy Mahrous 401 Postaholic Featured Poster

If you know anything about it. Its Text or its Name you can add a condition

foreach(Control c in Panel1.Controls)
{
if(c is TextBox)
if(c.Name = "field1") //or any property c.Text = "" or c.....
MessageBox.Show(string.Format("TextBox Name: {0} , TextBox Text {1}",c.Name, c.Text));
}
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

@Scott

In this class file i created an instance of "Card" structure successfully as shown in above code. But i cannot access the properties of structure like this(as shown bleow):

i created an instance of "Card" structure successfully as shown in above code
I bet there's no problem, I believe they have problem in something else.

Ramy Mahrous 401 Postaholic Featured Poster

Ema005 who said it's private the default is internal and it's!, and they can use it in the same assembly.
I take the code and run it, no problem.

Ramy Mahrous 401 Postaholic Featured Poster

You've something wrong it should work right.

Ramy Mahrous 401 Postaholic Featured Poster

What the at runtime created controls? TextBoxes or Buttons ?
If TextBoxes
You can add reference to recent created textbox name and perform the calculation
I.e: We created textbox its name textbox15

string recentTextBoxName = GetRecentCreatedTextBox();
string GetRecentCreatedTextBox()
{
///creating textbox at runtime
///return its name
}
void PerformCalcualtion(string textBoxName)
{
foreach(Control c in Controls)
if(c is TextBox)
if(c.Name == textBoxName)
//perform calculation on c
}

If buttons
when you create button assign a handler to it

///initialize controls properties
button1.Click+=new EventHandler(button_Click);
button2.Click+=new EventHandler(button_Click);
button3.Click+=new EventHandler(button_Click);

void button_Click(object sender, EventArgs)
{
///some code
}
Ramy Mahrous 401 Postaholic Featured Poster

Go ahead :)

Ramy Mahrous 401 Postaholic Featured Poster

You'll need to play with DataBound Event Handler, read this post http://www.csharphelp.com/archives/archive151.html and try to apply the concept on your case
Google result: http://www.google.com.eg/search?rlz=1C1CHMB_enEG312EG313&sourceid=chrome&ie=UTF-8&q=databound+grid+combobox+C%23

Ramy Mahrous 401 Postaholic Featured Poster

Please use code tag :)

static void Main(string[] args)
{
//code to call the method Getnames and print the value of name here..
Demo d = new Demo();
List<MyTest> m = new List<MyTest>();
d.GetNames<MyTest>(m);            
}
Ramy Mahrous 401 Postaholic Featured Poster

Welcome to Tugce and every Turkish people here and every where, I said why Serkan gave me reputation points :D now I knew, I've no problem I'll gave you when I celebrate 9th power strength :D
You didn't add on MSN did you still at your job since last message I sent you?

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

Is that the inside repeater or so?

Ramy Mahrous 401 Postaholic Featured Poster

Yes, Scott I was search about Scope_Identity yesterday I totally forgot it, thanks :)

Ramy Mahrous 401 Postaholic Featured Poster

Please mark it as solved if it's.

Ramy Mahrous 401 Postaholic Featured Poster

I expect you've auto increment identifier

Create proc InsertSP
@somevalues
AS
INSERT INTO YourTable Values(....)
SELECT MAX(PK) FROM yourTable

Then call the InsertSP

btn_click()
{
MessageBox.Show(GetValue("InsertSP").ToString());
}

Object GetValue (string procName)
{
//I didn't assume stored procedure takes parameters.
SqlConnection conn = new SqlConnection(...);
SqlCommand com = new SqlCommand(procName, conn);
com.CommandType = CommandType.StoredProcedure;
conn.Open();
com.ExecuteScalar();
}
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

If your stored procedure returns value just one value (which returns form aggregate functions) use SqlCommand and give it stored procedure name and then execute it as Scalar; it returns object you then can cast it

Object GetValue (string procName)
{
//I didn't assume stored procedure takes parameters.
SqlConnection conn = new SqlConnection(...);
SqlCommand com = new SqlCommand(procName, conn);
com.CommandType = CommandType.StoredProcedure;
conn.Open();
com.ExecuteScalar();
}
Ramy Mahrous 401 Postaholic Featured Poster

You don't beat up anyone you just talking much by not good way, I feel that Dani is your home and you're the one who says who should do what, if your don't like Serkan don't offense him personally and reply in a good manner PLEASE!

jephthah commented: kum-bah-YAHHHH m'lord... kum-bah-yah.... +12
iamthwee commented: 'Don't offense him' it should be 'don't offend him' -4
Ramy Mahrous 401 Postaholic Featured Poster

@William. Serkan asks something politely, doesn't he? and your reply is somewhat harsh please don't offense people. everyone in the community is part of it, you == me == Serkan == Salem == Dani, no one can let this community stand up without others help, if anyone criticize me it doesn't mean I'm good or bad, it means how others see me and I should take his words in my consideration and I debate this is the best thread Serkan wrote not because the subject has my name, I don't care but what I need to say kindly, don't offense someone did dozen of threads marked as SOLVED and when he asks and no one answers he posts the full answer + sample application.

Ramy Mahrous 401 Postaholic Featured Poster

Best of luck, man :)

Ramy Mahrous 401 Postaholic Featured Poster

Look Serkan I didn't fully understand your question what specific functionality you are looking for but every item on the subject and how to talk to it using .NET, I just searched for windows shell API C# and I found some posts, Am I right?
http://www.codeproject.com/KB/cs/decompresswinshellapics.aspx

Ramy Mahrous 401 Postaholic Featured Poster

If the criteria for being featured are post count, solved thread count, and reputation points

then what??? looool what's the criteria?? I swear I'm not looking for any award from any kind but just I wanted to comment on this line :) I just need to nominate Danny he deserves it.

Ramy Mahrous 401 Postaholic Featured Poster

I'm going to write a lot of code snippets.

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

You can add different RichTextBox to handle this, and append data to the RichTextBox programtically.

Ramy Mahrous 401 Postaholic Featured Poster

To allow multiple selection from report parameters check Multi-value