Forum Topic

C# (C Sharp) Programming Thread

  • guys sino naka work sa Sitecore and Sitecore Rocks diyan?

    anyone
  • Noob question lang kapag C# ang gamit na programming language ano usually pwedeng gamitin na database na gamit? TIA!
  • Microsoft SQL, MySQL, MSAccess
  • any database as long as merong right set of connection libraries.
  • mataas ba ang demand for wpf developers? puro asp.net kse nkkta ko sa job openings
  • guys paano ba ung code sa double click sa mouse ? indi ung single lang siya. i mean pag ka single click lang di muna siya mag aappear pero once na nag double click na . dun palang siya mag aappear . ganito kasi program ko using datagridview w/ database tapos mag aapear ung name sa textbox. ang kaso gusto sana double click tapos mag aappear siya dun sa textbox. thanks.
  • Meron event for double clicks... DoubleClickedEvent
  • ^hmm san kaya siya pwede ilagay ? un nalang kasi ung problem ko e. dapat naka disabled ung single click tapos saka lang siya gagana pag ka dinobol click mo siya.
  • Kung walang event for the single-click, wala naman action na mangyayari... eto medyo sinipag ako:


  • BTW, Person is a class I created:

  • ^Ah un pala ung babaguhin ko , sa may bandang "CellDoubleClick" Contentlink lang ata ung na post ko nun . olats kanina sayang. hahah, at least alam ko na din. Thank you sir.
  • guys pa tulong naman po , meron ba kayong program para sa traffic light ? thanks
  • Sir, question lang paano po ba pag ganito ? ung sa datagridview ko . gusto ko po sana once na Click ko ung "Manila to Cebu" and pagka press ko nung "GO button" papasok po siya sa listbox. paano po ba ung coding niya ? C# po pala. pasencia na mejo baguhan lang po . salamat.



  • eto yung full code. not the perfect solution but does the job. kung gusto mo yung files pm mo lang ako.

    namespace sendtolistwinforms
    {
    public partial class Form1 : Form
    {
    public Form1()
    {
    InitializeComponent();
    }

    private void Form1_Load(object sender, EventArgs e)
    {
    List<Destinations> dest = new List<Destinations>();
    dest.Add(new Destinations() { FromTo ="Manila To Cebu", Airline = "Boeing 747" });
    dest.Add(new Destinations() { FromTo = "Manila To Aklan", Airline = "Boeing 7471" });
    dest.Add(new Destinations() { FromTo = "Manila To TawiTawi", Airline = "Boeing 7472" });
    dest.Add(new Destinations() { FromTo = "Manila To Malaysia", Airline = "Boeing 7473" });
    dest.Add(new Destinations() { FromTo = "Manila To Singapore", Airline = "Boeing 7475" });

    this.dataGridView1.DataSource = dest;
    }

    private void button1_Click(object sender, EventArgs e)
    {
    var selected = this.dataGridView1.SelectedRows[0];
    if (selected != null)
    {
    listBox1.Items.Add(selected.Cells[0].Value.ToString());
    }
    }
    }

    public class Destinations
    {
    public string FromTo { get; set; }
    public string Airline { get; set; }
    }
    }
  • mga sir/mam,

    tama ba intindi ko. for example meron ako na create na WPF application na meron SQL Server as my datasource, ibig sabihin pwede ko na i deploy/install yung application ko on multiple PC (clients) and accessing the same datasource (Database server) within the same intranet.

    Indi ko na kailangan nang socket or WCF programming tama ba?
  • @myuser, as long as your database host can be access on the clients pc it\'ll work.

    To add, you can also use WCF if you want to build a service oriented application. By using WCF your application talks to your contract services and not directly thru your db. Somehow, this approach can give you flexibility also, like if you want to change your db in the future, the change will only be on the WCF side.

    -- edited by vivenz on Mar 31 2014, 05:38 PM
  • wala ba talaga pin/unpin tsaka close ang standard DockPanel? kasi lahat nang sample nang xaml sa internet parang wala tapos may nakita ako kelangan pa gumamit nang 3rd party.

    -- edited by myuser on Apr 05 2014, 11:54 PM
  • anybody here who has an idea to prevent a control from painting its background? currently I am working on a C# app for Windows CE for an embedded system device and the speed of the device is around 400MHz. I am drawing some GDI stuffs and created my own doublebuffering (no built in option for double buffering sa .NET compact framework :( ) and override the OnPaintBackground and do nothing. Doublebuffering alone doesnt solve the flickering but the background painting must be disabled as well. Now, I have lots of controls and they flicker everytime I navigate to another form, I think the background painting plays its part as well. This means I have to subclass all the controls and override the OnPaintBackground. Is there an easier way to disable the background painting nung mga controls na nag inherit sa Control class? already checked stackoverflow and their recommendation is to override the OnPaintBackground.
  • @sevenstring

    How many controls (types) are there? If all else fails and you have about 10 controls, I think subclassing and overriding the OnPaintBackground method would not hurt...
  • based sa estimate namin sir all controls will reach around 20 to 30 cguro. i think im a little bit ok with overriding the onpaintbackground. i just hope meron sanang properies na pwedeng iset as true or false para dito hehe...
  • anyone can recommend books or online tutorial sites for WCF programming?
  • ang c# po ba ay parang drag and drop lang din tulad ng vb.net at saka paano po yung tinatawag na mvc sa c#?
  • testing...
  • I have been programming in dotnet for a while now. Bookmarking this thread now...
  • Matagal-tagal na din ako gumagamit ng C#. I'm also using .NET Core para mapatakbo sa linux.
  • I wish mas active tong thread...
  • Post deleted #12095692
  • [img][img]patulong naman po, ako po ay gumawa ng application para mag monitor at mag manage ng aircon, ang software na ginamit ko ay arduino ide at c# at hardware naman ay: arduino uno, jumping wires, at 4 channel relay.

    ang problema ay: hindi madetect ng application kung on/off yung aircon, dapat pagopen ng app nadetect na niya kung ano yung state ng aircon either on or off siya.



    C# Source Codes

    using System;
    using System.Collections.Generic;
    using System.ComponentModel;
    using System.Data;
    using System.Drawing;
    using System.Linq;
    using System.Text;
    using System.Threading.Tasks;
    using System.Windows.Forms;
    using System.Data.SqlClient;
    namespace Aircon_UI
    {

    public partial class Form1 : Form
    {

    bool off_ac1 = false;
    bool off_ac2 = false;
    bool off_ac3 = false;
    bool off_ac4 = false;
    string on1 = "Aircon 1 is ON, ";
    string on2 = "Aircon 2 is ON, ";
    string on3 = "Aircon 3 is ON, ";
    string on4 = "Aircon 2 is ON.";
    string off1 = "Aircon 1 is OFF, ";
    string off2 = "Aircon 2 is OFF, ";
    string off3 = "Aircon 3 is OFF, ";
    string off4 = "Aircon 4 is OFF.";
    public Form1()
    {
    InitializeComponent();

    }
    private void button1_Click(object sender, EventArgs e)

    {
    serialPort1.Open();

    MessageBox.Show("System started!");
    button1.Enabled = false;
    button2.Enabled = true;
    button3.Enabled = true;
    button4.Enabled = true;
    button6.Enabled = true;
    button7.Enabled = true;

    if (off_ac1)
    {
    button2.Text = "OFF";
    button2.BackColor = Color.Gray;
    off_ac1 = false;
    serialPort1.Write("1");
    textBox1.Text = off1;
    }
    else
    {
    button2.Text = "ON";
    button2.BackColor = Color.Yellow;
    off_ac1 = true;
    serialPort1.Write("0");
    textBox1.Text = on1;
    }
    }
    private void button3_Click(object sender, EventArgs e)
    {
    if (off_ac2)
    {
    button3.Text = "OFF";
    button3.BackColor = Color.Gray;
    off_ac2 = false;
    serialPort1.Write("2");
    textBox1.Text = off2;
    }
    else
    {
    button3.Text = "ON";
    button3.BackColor = Color.Yellow;
    off_ac2 = true;
    serialPort1.Write("3");
    textBox1.Text = on2;
    }
    }
    private void Form1_Load(object sender, EventArgs e)
    {
    if (button1.Enabled == true)
    {
    button2.Enabled = false;
    button3.Enabled = false;
    button4.Enabled = false;

    button6.Enabled = false;
    button7.Enabled = false;
    }
    }
    private void button5_Click(object sender, EventArgs e)
    {
    Application.Exit();
    serialPort1.Close();
    }
    private void textBox1_TextChanged(object sender, EventArgs e)
    {
    }
    private void button4_Click(object sender, EventArgs e)
    {

    if (off_ac1 == true && off_ac2 == true && off_ac3 == true && off_ac4 == true)
    {
    textBox1.Text = on1 + on2 + on3 + on4;
    }
    if (off_ac1 == false && off_ac2 == false && off_ac3 == false && off_ac4 == false)
    {
    textBox1.Text = off1 + off2 + off3 + off4;
    }
    if (off_ac1 == false && off_ac2 == true && off_ac3 == true && off_ac4 == true)
    {
    textBox1.Text = off1 + on2 + on3 + on4;
    }
    if (off_ac1 == false && off_ac2 == false && off_ac3 == true && off_ac4 == true)
    {
    textBox1.Text = off1 + off2 + on3 + on4;
    }
    if (off_ac1 == false && off_ac2 == false && off_ac3 == false && off_ac4 == true)
    {
    textBox1.Text = off1 + off2 + off3 + on4;
    }
    if (off_ac1 == true && off_ac2 == true && off_ac3 == true && off_ac4 == false)
    {
    textBox1.Text = on1 + on2 + on3 + off4;
    }
    if (off_ac1 == true && off_ac2 == true && off_ac3 == false && off_ac4 == false)
    {
    textBox1.Text = on1 + on2 + off3 + off4;
    }
    if (off_ac1 == true && off_ac2 == false && off_ac3 == false && off_ac4 == false)
    {
    textBox1.Text = on1 + off2 + off3 + off4;
    }
    if (off_ac1 == true && off_ac2 == false && off_ac3 == true && off_ac4 == false)
    {
    textBox1.Text = on1 + off2 + on3 + off4;
    }
    if (off_ac1 == false && off_ac2 == true && off_ac3 == false && off_ac4 == true)
    {
    textBox1.Text = off1 + on2 + off3 + on4;
    }
    if (off_ac1 == false && off_ac2 == true && off_ac3 == false && off_ac4 == false)
    {
    textBox1.Text = off1 + on2 + off3 + off4;
    }
    if (off_ac1 == false && off_ac2 == false && off_ac3 == true && off_ac4 == false)
    {
    textBox1.Text = off1 + off2 + on3 + off4;
    }
    if (off_ac1 == true && off_ac2 == false && off_ac3 == true && off_ac4 == true)
    {
    textBox1.Text = on1 + off2 + on3 + on4;
    }
    if (off_ac1 == true && off_ac2 == true && off_ac3 == false && off_ac4 == true)
    {
    textBox1.Text = on1 + on2 + off3 + on4;
    }
    if (off_ac1 == true && off_ac2 == false && off_ac3 == false && off_ac4 == true)
    {
    textBox1.Text = on1 + off2 + off3 + on4;
    }
    if (off_ac1 == false && off_ac2 == true && off_ac3 == true && off_ac4 == false)
    {
    textBox1.Text = off1 + on2 + on3 + off4;
    }
    }
    private void button2_Click_1(object sender, EventArgs e)
    {
    if (off_ac1)
    {
    button2.Text = "OFF";
    button2.BackColor = Color.Gray;
    off_ac1 = false;
    serialPort1.Write("1");
    textBox1.Text = off1;
    }
    else
    {
    button2.Text = "ON";
    button2.BackColor = Color.Yellow;
    off_ac1 = true;
    serialPort1.Write("0");
    textBox1.Text = on1;
    }

    }

    private void button6_Click(object sender, EventArgs e)
    {
    if (off_ac3)
    {
    button6.Text = "OFF";
    button6.BackColor = Color.Gray;
    off_ac3 = false;
    serialPort1.Write("4");
    textBox1.Text = off3;
    }
    else
    {
    button6.Text = "ON";
    button6.BackColor = Color.Yellow;
    off_ac3 = true;
    serialPort1.Write("5");
    textBox1.Text = on3;
    }
    }

    private void button7_Click(object sender, EventArgs e)
    {
    if (off_ac4)
    {
    button7.Text = "OFF";
    button7.BackColor = Color.Gray;
    off_ac4 = false;
    serialPort1.Write("6");
    textBox1.Text = off4;
    }
    else
    {
    button7.Text = "ON";
    button7.BackColor = Color.Yellow;
    off_ac4 = true;
    serialPort1.Write("7");
    textBox1.Text = on4;
    }
    }

    private void groupBox2_Enter(object sender, EventArgs e)
    {

    }

    private void groupBox3_Enter(object sender, EventArgs e)
    {

    }

    private void serialPort1_DataReceived(object sender, System.IO.Ports.SerialDataReceivedEventArgs e)
    {
    }
    }
    }


    Arduino Source Codes
    char incomingOption;
    void setup() {
    pinMode(13,OUTPUT);
    pinMode(12,OUTPUT);
    pinMode(11,OUTPUT);
    pinMode(10,OUTPUT);
    Serial.begin(9600);
    }
    void loop() {

    incomingOption = Serial.read();
    if (incomingOption ='1')
    {
    digitalWrite(13,HIGH);
    }
    else if (incomingOption ='0')
    {
    digitalWrite(13,LOW);
    }
    if (incomingOption='2')
    {
    digitalWrite(12,HIGH);
    }
    else if (incomingOption='3')
    {
    digitalWrite(12,LOW);
    }
    if (incomingOption='4')
    {
    digitalWrite(11,HIGH);
    }
    else if (incomingOption='5')
    {
    digitalWrite(11,LOW);
    }
    if (incomingOption='6')
    {
    digitalWrite(10,HIGH);
    }
    else if (incomingOption='7')
    {
    digitalWrite(10,LOW);

    }
    }
  • @monalmendra

    Although you're using C#, your problem is using the Arduino API or IDE, I think you would get better answers in the Arduino thread...
  • doon sa arduino code mo digitalwrite at serial read lang ang ginagawa nun. dapat itransmit ng arduino yung current state ng pin ng arduino papuntang , you can use shadow variable or read the state nung pins at mag serial transmit papuntang C# app.