C # Tips 2

Source: Internet
Author: User

C # textbox auto scroll to end scrolltocaret scrolling textbox
Usage of my sample C # codes,
I use textbox to write the results.

When textbox is multiline property set to true, and when I insert text into it,
I want it to auto scroll to the last line.

Here is a simple way to auto scrolling textbox.

Textbox1.selectionstart = textbox1.text. length;
Textbox1.scrolltocaret ();
Textbox1.refresh ();

Textbox selectionstart will force the Textbox Control to select the last part of the text,
And scrolltocaret () function will auto scroll textbox to the end.

 

C # convert hexadecimal to binary String Conversion

There is no need to code tons of codes, loops, to convertHEX to binary string.Convert. toint32Function is very useful for this purpose.
Let's convert the "A" character to binary format.

private string hex2binary(string hexvalue)
{
string binaryval = "";
binaryval = Convert.ToString(Convert.ToInt32(hexvalue, 16), 2);
return binaryval;
}

When we callHex2binary("A"); it will return "1010" similar samples below;
Hex2binary("1a"); Will return"11010";
Hex2bianry("1a2c"); Will return"1101000101100"; And so on.
Keep in mind that thisHEX to Binary ConversionStyle uses32 bit integerNumber.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.