Posts

Showing posts from July, 2013

How to get random element from integer array in c#.net

Image
Now for generating random element from the array first you have to generate the random number and using this random number you can get the random element form the array.   Code : -                     // array of integer                   int[] a={10,20,30,40,50,60,70,80,90};             Random rnd = new Random();             int b = rnd.Next(0,5);             //show the random element in text box             textBox1.Text = a[b].ToString(); For Generating Random rows from dataset here 

How to Generate random rows in dataset using c#.net

Image
For generating the random rows from the data set first you have to generate the random numbae and this number is pass to the dataset CODE:  SqlConnection con = new SqlConnection("Data Source=NIRAV-PC;Initial Catalog=Student;Integrated Security=True");             con.Open();             string str = "select * from StudentDetail";             SqlCommand cmd =new SqlCommand(str,con);             SqlDataAdapter sda = new SqlDataAdapter(cmd);             DataSet ds =new DataSet();             sda.Fill(ds);             Random RandomNumber = new Random();             int no = RandomNumber.Next(0,ds.Tables[0].Rows. Count);             textBox1.Text = ds.Tables[0].Rows[no][0].ToString();           

How to resize form In C#.Net

Image
             For Resizing of form programmatically using c#.net is very easy. Here we give some code which is use to resize the form .by using this code you can make animation like application in c#.net also. Here in my application user can enter size (width and height) of the form and on click event of the button he resize the form as per its requirements For resizing form when form is in maximize state it not possible so firs we have to set state of form to be normal then we apply the. height and width properties to the form. private void button1_Click(object sender, EventArgs e) {             if (this.WindowState==FormWindowState.Maximized)             {                 this.WindowState = FormWindowState.Normal;             }             if (textBox1.Text!="" && textBox2.Text!="" )             {                 this.Width = Convert.ToInt16(textBox1.Text.Trim());                 this.Height = Convert.ToInt16(textBox2.Text.Trim());             }   }  Dow

Ticket Generation Using C#.net

Image
                              This article show and learns about how to generate the ticket using c#.net. This describe the how actually ticket (bus ticket) is generate what it will use any how it work              This article presents a solution to solving ticket generation problem using C# and Visual Studio 2010. This application is multipurpose application. This article is use full for many purpose for example city bus ticket generation, store retail ticket generation, in fair for rider tickets etc. This application will solve problem of how to print ticket, how to set margin of text for ticketetc. Follow the Steps: Step -1 In this tutorial first you have to add namespace using System.Drawing.Printing; now start with fist make object of the print document   ‘pd’.this will   make one document on which you have to draw or write content PrintDocument pd = new PrintDocument (); Then you have to make object of the paper size this will take arguments as name, width, height this defin