วันจันทร์ที่ 18 พฤษภาคม พ.ศ. 2563

วันอังคารที่ 5 พฤษภาคม พ.ศ. 2563

ตรวจสอบสถานะ Connection

var sqlCon= new SqlConnection(Properties.Settings.Default.sString);
var mySQLCon= new MySqlConnection(Properties.Settings.Default.dString);
sqlCon.Open();
mySQLCon.Open();
var temp = mySQLConn.State.ToString();
if (sqlCon.State==ConnectionState.Open && temp=="Open")
 {
   MessageBox.Show(@"Connection working.");
 }
else
 {
  MessageBox.Show(@"Please check connection string");
 }

grid control datasource

grid cell allignment

gridView2.Columns[i].AppearanceCell.TextOptions.HAlignment = HorzAlignment.Center;

gridcontrol Column Header

ASPxGridView1.Columns[0].Caption = "Some Value";

จัดหัวตารางอยู่กึ่งกลาง
int ccount = gridView2.Columns.Count;
for (int i = 0; i <= ccount-1; i++)
{
gridView2.Columns[i].AppearanceHeader.TextOptions.HAlignment = HorzAlignment.Center;
gridView2.Columns[i].AppearanceHeader.Options.UseTextOptions = true;
}

gridcontrol Caption

gridview properties


OptionView->ShowViewCaption=true
viewcaption="ชื่อวิว"

ตรวจสอบ textbox คีย์ตัวเลข

            if (txtpidsearch.TextLength > 0)
            {
                int parsedValue;
                if (!int.TryParse(txtpidsearch.Text, out parsedValue))
                {
                    MessageBox.Show("กรอกเฉพาะตัวเลข !!!");
                    return;
                }
                else
                {}
              }
             else
             {}