Ok Thank You Very Much for Given Me Time And Solved My Problem

 //Write/Save File as RichText 
  private void btnwrite_Click(object sender, EventArgs e)

            richTextBox1.ForeColor = Color.Red;
            richTextBox1.Font = new Font(richTextBox1.Font, FontStyle.Bold);
            richTextBox1.SaveFile(@"D:/myFile.rtf", RichTextBoxStreamType.RichText);
        // Read File from D Drive as RichText
 private void btnRead_Click(object sender, EventArgs e)
            richTextBox2.LoadFile(@"D:/myFile.rtf", RichTextBoxStreamType.RichText);

        //Show RichText in Label
                           // Here is Problem I show text but not forecolor and not font
         private void btnshowtext_Click(object sender, EventArgs e)

            label1.Text = richTextBox2.Text;
            label1.ForeColor = richTextBox2.ForeColor;
            label1.Font = richTextBox2.Font;

I hope You Understood my Problem Please Help

Ihave already do that

label1.text = RitchTextBox1.text;
Label1.ForeColor = RitchTextBox1.ForeColor
Label1.Font = RitchTextBox1.Font;

But It Could not Work.Text show in label but it font and color doesn't show.Please Help

How Can Transferdata from RitchTextBox to Label with all Formats. i.e RitchTextBox's Text Color ,Font,FontStyle

Send Value from Form1 to Form2 You can use this code
In Form1

private void btnsendvalue_Click(object sender, EventArgs e)

           Form2 form2 = new Form2(TextBox1.Text +"SurName "+ TextBox2.Text);

and in Form2 use this code

public Form2 (string text)
            label1.Text = text;

Hope this Help You

thanks nick.crane ,You solved the problem .

and Thanks for Lamouche and Mitja Bonca

How I perform with iteration
As a Loop

I have a form of c sharp, In winch I have Five Button.I want hit all buttons one by one dynamically.
Please send me complete Code of c sharp.

Yes,This is .Mitja You are the best programmer at daniweb.my problem has been solved by your query[CODE]"SELECT LastBalance FROM Students WHERE StudentID = @id";[/CODE]

I have a database
Please tell me how can i get [B]Last Balance[/B] from sql server

Ok this thread is solved by ddanbe.It should be datetimePicker.and So Sorry Mitja I could not explain,what i'm want to do.

Hello Sir this is not Solution of my question I want Students age must be minimum 6 years old.If Student's age is 10 years old Messagebox show "You can not admit in this School".

I have a Textbox named txtage.text.Now I want When Insert in txtage.text as 30/12/1980.
disable tabindex.and messagebox show "You can not give admission".If Insert in txtage.text as 30/12/2005.
Enable Tab index .its mean student 's age must be 6 year not greater nor less.

Ok Sir Mitja its was my fault i was not understanding Your point.now It Problem has been solved the code is under
[CODE]Pictureid [COLOR="Green"]int[/COLOR][/CODE][CODE]picture[COLOR="green"]varbinary(Max)[/COLOR][/CODE]
and c# code is
[CODE]using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using System.Data.SqlClient;
using System.IO;
namespace StoreImagesInSQLServer
public partial class frmNewImage : Form
public frmNewImage()

    private void cmdSave_Click(object sender, EventArgs e)
            //Read Image Bytes into a byte array
            byte[] imageData = ReadFile(txtImagePath.Text);

            //Initialize SQL Server Connection
            SqlConnection CN = new SqlConnection(txtConnectionString.Text);

            //Set insert query
            string qry = "insert into Imageform(Picture) values(@Picture)";

            //Initialize SqlCommand object for insert.
            SqlCommand SqlCom = new SqlCommand(qry, CN);

            //We are passing Original Image Path and Image byte data as sql parameters.
           /* SqlCom.Parameters.Add(new SqlParameter("@OriginalPath", (object)txtImagePath.Text));
            * */
            SqlCom.Parameters.Add(new SqlParameter("@Picture", (object)imageData));

            //Open connection and execute insert query.

            //Close form and return to list or images.
        catch(Exception ex)
            MessageBox.Show(ex.Message );

    private void cmdBrowse_Click(object sender, EventArgs e)
        //Ask user to select file.
        OpenFileDialog dlg = new OpenFileDialog();
        DialogResult dlgRes = dlg.ShowDialog();
        if (dlgRes != DialogResult.Cancel)
            //Set image in picture box
            pictureBox1.ImageLocation = dlg.FileName;

            //Provide file path in txtImagePath text box.
            txtImagePath.Text = dlg.FileName;

    //Open file in to a filestream and read data in a byte array.
    byte[] ReadFile(string sPath)
        //Initialize byte array with a null value initially.
        byte[] data = null;

        //Use FileInfo object to get file size.
        FileInfo fInfo = new FileInfo(sPath);
        long numBytes = fInfo.Length; ...

Ok My Database name is [COLOR="Red"]Imagetable[/COLOR] and In this table there are
[COLOR="red"]Pictureid [COLOR="Green"]Int[/COLOR][/COLOR] [COLOR="Red"]Picturename [COLOR="Green"]varchar(50)[/COLOR][/COLOR][COLOR="Red"]Picture[COLOR="Green"]Image[/COLOR][/COLOR]
My store Procedure is

ALTER procedure [dbo].[imageinsert]
@pictureid int,
@picturename varchar(50),
@picture Image

insert Imagetable(Pictureid,picturename,picture)
Values (@pictureid,@picturename,@picture)
Now Please Help Me.

Hello Sir Mitja I already visited this cite and could not understand.[COLOR="Red"]But I Always Understand of Your Code [/COLOR]Because it always simple and perfect.So Please Tell Me and solved my problem.

[COLOR="Green"]Thanks [/COLOR]

Hello Experts

Here is my connection string
[CODE] string con = "Data source =YS-8462BA359936;Initial Catalog = Schooldata;Integrated Security = True";[/CODE]
and my store procedure is
SqlConnection objCon = new SqlConnection(con);

            SqlCommand cmd = new SqlCommand("Studentinsertadmission", objCon);

cmd.Parameters.Add(new SqlParameter("@Studentid",Convert.ToInt32( studentid.Text)));
cmd.Parameters.Add(new SqlParameter("@StudentName", firstname.Text));
cmd.Parameters.Add(new SqlParameter("@Image", image.image ));

cmd.CommandType = CommandType.StoredProcedure;
int rows = cmd.ExecuteNonQuery();

            MessageBox.Show("Record Inserted Successfully! ");


But i am not able to load picture in picture box and also save in sql database
Please Solve my Problem

Oh Sorry Momerath This was my fault I was not able to use your code.[COLOR="Green"]Now This Problem is completely Solved [/COLOR]
[CODE] public void SetLable1(string connString)
connString = "Data Source = YS-8462BA359936;Initial Catalog=Schooldata;Integrated Security = True";

        int totalCustomer = 0;
        string sql = "SELECT COUNT(Studentid) FROM studentinfo";
        using (SqlConnection conn = new SqlConnection(connString))
            SqlCommand cmd = new SqlCommand(sql, conn);
                totalCustomer = (Int32)cmd.ExecuteScalar();
            catch (Exception ex)
        label1.Text = totalCustomer.ToString();

private void button1_Click(object sender, EventArgs e)

Thanks for[B]Momerath,ChrisHunter,
Mitja Bonca[/B]

What I Do ?My Problem is still.
Now I Run [COLOR="Red"]Momerath[/COLOR] Code But It get result -1.But in my studentid table there are 10 Rows.this is code
[CODE] private void button5_Click(object sender, EventArgs e)
string conn = "Data Source = YS-8462BA359936;Initial Catalog=Schooldata;Integrated Security = True";

        int Studentid = 0;
        SqlConnection objCon = new SqlConnection(conn);
        SqlCommand cmd = new SqlCommand("select studentid from studentinfo", objCon);
        Studentid = cmd.ExecuteNonQuery();


        MessageBox.Show("Total Number Of StudentID are! "+Studentid.ToString());

[COLOR="red"]Please Friends Help me I am In big trouble [/COLOR]

When I want get result in label it gives me error
[CODE]string conn = "Data Source = YS-8462BA359936;Initial Catalog=Schooldata;Integrated Security = True";
SqlConnection objCon = new SqlConnection(conn);
SqlDataAdapter objDA = new SqlDataAdapter("SELECT COUNT(Studentid) from studentinfo", objCon);
label1.text = objda;[/CODE] The total of studentid not seen in label.When I type code with datagrid result always correct [CODE]DataTable objDT = new DataTable();
this.dataGridView2.DataSource = objDT;
[/CODE][COLOR="Red"][B] but I want get total result in label[/B][/COLOR]

I am not Giving the result Please more help
My Connection String is as below
[CODE]string conn = "Data Source = YS-8462BA359936;Initial Catalog=Schooldata;Integrated Security = True";
SqlConnection objCon = new SqlConnection(conn);
SqlDataAdapter objDA = new SqlDataAdapter("SELECT COUNT(Studentid) from studentinfo", objCon);[/CODE] how can I get total result in label1

I have a database in which

customerid CustomerName
1 ------------- Yousaf
2 ------------- Aslam
3 -------------Manga
4 ------------- ABC

Now I want Count customerid Row. How can i do it
In SQL SERVER I write the query [CODE]Select Count(Customerid) from studentinfo
[/CODE]And I get Total Customer.

[B][COLOR="Red"]I want display total customerid in label[/COLOR][/B]
Please Help me As soon As Possible
Thanks in Advance

Oh Really thanks to [COLOR="Red"][B]stbuchok[/B][/COLOR]
It Solved my Problem and i got result with [COLOR="Green"][B]Studentinfo.studentid[/B][/COLOR]

What is Wrong in this code

[CODE]Select * from Studentinfo
Inner Join Admission
On Studentinfo.Studentid= admission.studentid
where Studentid= '1'[/CODE]

Please Help as soon as Possible

Ok.You have to do this
1- Uninstall processor , fan with heatsink .Clean the past on the processor.it called heatsink past.Now you clean prosessor area by air blour and also Uninstall the Ram and Bios Battery.Now plugin main for 20sec and plugout the main.

[COLOR="red"]RePaste Prosessor Never Install the prosessor without paste.[/COLOR]
now Pluging computer into main line.you will hear a little beep again again.
reinstall the Ram and Bater.Now i assuar you will watch display of your compuer

Hope This will Help You


oh [COLOR="Red"]Mitja[/COLOR] You solved this problem


i make a string array and want to show in message box,but it does not working properly
[COLOR="Red"]Help Me what is wrong [/COLOR]
[CODE] private void btnarray_Click(object sender, EventArgs e)
string[] myname = new string[2];
myname[0] = "Shahid";
myname[1] = "Hussain";


when message box show error show
[COLOR="orange"]Error is "System.string[]"[/COLOR]
But it does not show myname one by one

Thanks Mitja You solved this problem pleas send me such more game design i will try make it myself thanks

i want make game
This is game which has " x "label and "o" Two user Play this game
i am not understanding how can i create it .please Help

can i make myself simple game in c#. if yes then please[COLOR="Red"]send me code[/COLOR] for [COLOR="[B]red"]Tic Tac[/B] Toe[/COLOR]