Let's share our knowledge
Thursday, 19 April 2012
Wednesday, 18 April 2012
Saturday, 14 April 2012
Wednesday, 11 April 2012
C# :Count the total number of lines in RichTextBox
All you have to use is RichTextBox.GetLineFromCharIndex method.
You will find more detailed explanation here:
GetLineFromCharIndex[^]
Here is complete example of counting total number of lines in RTB
int lineNumber = richTextBox1.GetLineFromCharIndex(richTextBox1.TextLength) + 1; MessageBox.Show(lineNumber.ToString());This 2 lines of code will give you number of lines in RichTextBox
You will find more detailed explanation here:
GetLineFromCharIndex[^]
Here is complete example of counting total number of lines in RTB
Saturday, 7 April 2012
C#: Read from excel file
I used .NET 2.0 framework. Reading from excel file is depends on excel's version, not entirely but it will affect your source code little bit.
Here is little tip about reading excel file.
This function accepts 2 arguments which are describe excel file's name, and it's version.
If you are using excel 2007 then send true as a second argument, or else send false when you call this function.
Here is little tip about reading excel file.
string mFileName; // file name which you will read from. System.Data.OleDb.OleDbConnection connection; string mSheetName; // excel file consists of many sheets / pages. System.Data.OleDb.OleDbDataAdapter dtAdapter;Reading from excel file is as same as reading from database, so that you will need connection string which helps you to connect your program to excel sheets, as well as dataAdapter which will retrieve data from excel sheet.
This function accepts 2 arguments which are describe excel file's name, and it's version.
If you are using excel 2007 then send true as a second argument, or else send false when you call this function.
C#: Read from command Prompt
I've been trying to read from Command prompt using c#. My application supposed to read lines from cmd whatever it shows. My Purpose was developing code editor and using external compiler.
You need to use
You need to use
System.Diagnostics.Process(System.Diagnostics.ProcessStartInfo).
System.Diagnostics.ProcessStartInfo startInfo = new System.Diagnostics.ProcessStartInfo("file.exe", "command");
startInfo.RedirectStandardError = true;
startInfo.RedirectStandardOutput = true;
startInfo.StandardOutputEncoding = //change if you need, you might need it
startInfo.StandardErrorEncoding = //change if you need, you might need it
//...
Using this example,
file.exe
could be any executable file and command
, it should be related to exe file. In this example, file.exe is "cmd.exe" and "command" is "RUNCOB"PHP: How To Create Thumbnail image.
Someone may wonder that when we have Photoshop, why do we bother to create thumbnail images using Php? Well answer is quite easy, whenever you upload photos to your web site to attract your readers or someone, every time you will have to cut or crop or do something on your photos by manually. Is not it annoying?
Once you completed your few lines of code you will no longer suffer from editing photos.
Here is your source code.
Result :
Good luck
Once you completed your few lines of code you will no longer suffer from editing photos.
Here is your source code.
// Path of photo.$img_name="Gear2nd.sized.jpg";//In this case thumbnail image size will be twice smaller than its original.//based on original photo's size this size can be changed.$thm_size=2;// Typeheader('Content-type: image/jpeg');// Generating Thumbnail's size.list($width, $height)=getimagesize($img_name);$new_width=$width / $thm_size;$new_height =$height / $thm_size;// Generating thumbnail image$thm_img=imagecreatetruecolor($new_width, $new_height);$img=imagecreatefromjpeg($img_name);imagecopyresampled($thm_img, $img, 0, 0, 0, 0, $new_width, $new_height, $width, $height);// show off the thumbnailimagejpeg($thm_img, null,100);
Result :
Good luck
Subscribe to:
Posts (Atom)