Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
CODE PROJECT For Those Who Code
  • Home
  • Articles
  • FAQ
Community
A

alfie max15

@alfie max15
About
Posts
23
Topics
9
Shares
0
Groups
0
Followers
0
Following
0

Posts

Recent Best Controversial

  • Clear a tab contents when i switch tabs
    A alfie max15

    Thnx... I did consider your suggestion and used tab Deselecting event.... Thnx again...

    C# csharp visual-studio question

  • Clear a tab contents when i switch tabs
    A alfie max15

    I have a form in which i an using tab control. There are three tabs and in each tab there are textboxes. What i want to achieve is that when i switch from tab 1 to tab 2. All the textboxes of tab 1 should be cleared. Is it possible??? I am using Visual studio 2013, .NET 4.5, C#

    C# csharp visual-studio question

  • Close Form when not focused
    A alfie max15

    Thanks alot... It works...

    C# question

  • Close Form when not focused
    A alfie max15

    Wow... That worked like a charm... Thanks alot... M sorry but, i hadn't mentioned before, but there are two buttons on this second form, Which when clicked One opens the openfiledialog and the other folderbrowser. The problem is when i click any of the buttons it will bring up the Dialogs and so the form gets deactivated, as a result the dialog boxes also gets closed. :( Any way to work around this???

    C# question

  • Close Form when not focused
    A alfie max15

    I have a main form with a button, when pressed opens a second form. I want to make this form close when it is out of focused. I tried with a timer checking

    private void IsFocused_Tick (object sender, EventArgs e)
    {
    if(!this.Focused)
    {
    this.DialogResult = DialogResult.Cancel;
    }
    }

    But Nothing happens Can anyone tell me what i am doing wrong here?

    C# question

  • Returning objects from sub-form to main-form
    A alfie max15

    I have two forms, when a button is pressed on the main form a second form comes up with a button. This button when pressed brings up the OpenFileDialog. What i want to do is that After i select a file. this result should be returned to the main-form when i close the sub-form. Using VS2012, .NET 4.5, Windows forms App I have googled for many results, but it doesnt seem to work for me. I have tried passing main form instance to sub-form as

    SubForm subform = new SubForm(this);

    public partial class SubForm : Form
    {
    private MainForm mainForm;
    public SubForm(MainForm mainForm)
    {
    InitializeComponent();
    this.mainForm = mainForm;
    }
    }

    and then it was said that i could access objects of mainform from sub-from. But i cant. I also tried making a static main form instance

    static class Program
    {
    public static Form MainForm;

    /// <summary>
    /// The main entry point for the application.
    /// </summary>
    \[STAThread\]
    static void Main()
    {
        Application.EnableVisualStyles();
        Application.SetCompatibleTextRenderingDefault(false);
    
        MainForm = new Form1();
    
        Application.Run(MainForm);
    }
    

    }

    Still no use, Maybe someone has any other alternative??? Or maybe tell me what might i be doing wrong in the above solutions.

    C# csharp winforms question

  • Scroll into a Adobe Reader using buttons c#
    A alfie max15

    I tried it, but it did nothing, What was it supposed to do???

    C# csharp com adobe help

  • Scroll into a Adobe Reader using buttons c#
    A alfie max15

    I Have Created a Simple form in which i have added Adobe Reader from toolbox using steps 1. right click in toolbox - Choose Items 2. choose COM Components tab and there "Adobe PDF Reader" 3. Now Drag&Drop the Adobe PDF Reader Control into an UserControl I have successfully added this, opened up a pdf file also. Now it automatically provides with vertical scrollbars for scrolling through the pdf document. What i want to achieve is instead of using the given scrollbars or mouse to scroll, i want to use a button to scroll scroll the pdf, So there will be two buttons, One for Scroll Up And the other for scroll down. I have gone through many forums, pages, etc. Havnt found anythn that i could use. I have Tried Simulating key presses with

    SendKeys.Send("{DOWN}");

    But as i press the button, the focus is lost on the adobe reader so it doesnt work Pls help me... I have spent almost half a day searchin for a solution

    C# csharp com adobe help

  • Zoom in and Zoom out feature in a picturebox
    A alfie max15

    Hi there, I am using VS2012 and .NET Framework 4.5 I am making a simple picture viewer. I have completed, Creating a picture viewer, which has open, previous, and next buttons. Now i was wondering how i can add in the Zoom feature into this. What i exactly want is, according to mouse wheel movement the picture should zoom in or out corresponding to direction of rotation of the mouse wheel. Also the image should zoom in or out based on the point where the mouse pointer is currently present. One more thing, the picture viewer is fullscreen at all time. I hope somebody could reply soon... Thank you

    C# csharp dotnet

  • Reading from serial port
    A alfie max15

    Did just that as you said now, Removed all the

    SerialPort.Close()

    No change, output is good, but the application freezes after a while. When i try to make the terminal as earlier without event handler i am getting a perfect output with

    ReadExisting()

    But using the eventhandler, it just doesn't work as expected

    C# help

  • Reading from serial port
    A alfie max15

    I have two forms, the first one is the main form and creates the serial port instance and then i pass the serial port object into the second form which is the terminal form. The following code is the contents of the namespace of the second form

    bool Receive_Enable = false;

    public Terminal (SerialPort Serial_Port)
    {
    InitializeComponent ();
    _SerialPort = Serial_Port;
    _SerialPort.Close ();
    _SerialPort.DataReceived += new SerialDataReceivedEventHandler (Port_DataReceived);
    }

    private void Start_Click (object sender, EventArgs e)
    {
    if(Start.Text == "Start")
    {
    Start.Text = "Stop";
    _SerialPort.Open ();
    Receive_Enable = true;
    }
    else
    {
    Receive_Enable = false;
    _SerialPort.Close ();
    Start.Text = "Start";
    }
    }

    private void Port_DataReceived (object sender, SerialDataReceivedEventArgs e)
    {
    if(Receive_Enable)
    {
    rtbTerminal.AppendText (Convert.ToString (_SerialPort.ReadLine ()));
    rtbTerminal.ScrollToCaret ();
    }
    }

    Tried this.... Also tried with

    _SerialPort.ReadExisting ()

    The application freezes after few seconds.... :wtf: What to do???? :confused: Am i doing this right???

    C# help

  • Reading from serial port
    A alfie max15

    private void Start_Click (object sender, EventArgs e)
    {
    if(Start.Text == "Start")
    {
    Start.Text = "Stop";
    _SerialPort.DataReceived += new SerialDataReceivedEventHandler (Port_DataReceived);
    }
    else
    {
    Start.Text = "Start";
    }
    }

        private void Port\_DataReceived (object sender, SerialDataReceivedEventArgs e)
        {
            string data = \_SerialPort.ReadExisting ();
            rtbTerminal.AppendText (data);
            rtbTerminal.ScrollToCaret ();
        }
    

    private void Start_Click (object sender, EventArgs e)
    {
    if(Start.Text == "Start")
    {
    Start.Text = "Stop";
    _SerialPort.DataReceived += new SerialDataReceivedEventHandler (Port_DataReceived);
    }
    else
    {
    Start.Text = "Start";
    }
    }

        private void Port\_DataReceived (object sender, SerialDataReceivedEventArgs e)
        {
            string data = \_SerialPort.ReadExisting ();
    
            rtbTerminal.Invoke (new EventHandler (delegate
            {
                rtbTerminal.SelectedText = string.Empty;
                rtbTerminal.AppendText (data);
                rtbTerminal.ScrollToCaret ();
            }));
        }
    

    I have tried both ways above.

    C# help

  • Reading from serial port
    A alfie max15

    OriginalGriff wrote:

    Instead, handle the SerialPort.DataReceived[^] event, and get the data in that using ReadExisting - you can then add the data to the textbox in the event handler

    Sorry forgot to mention, i had tried that too... Same problem. losing data....

    C# help

  • Reading from serial port
    A alfie max15

    jschell wrote:

    If your source for the characters are human input is human than it seems unlikely that ReadExisting() would lose anything.

    the characters are not human input. its source is a micro controller ADC output. So it continuously sends data to the serial port. Parity - Even Databits - 8 Stopbits - 2 Baudrate - 4800

    jschell wrote:

    ReadLine() blocks until a new line character occurs so you can't expect it to do anything immediately based on a key press unless the key causes a end of line.

    The button press calls the

    serialport.Close();

    so then it shouldn't matter what the

    ReadLine()

    function gets.

    C# help

  • Reading from serial port
    A alfie max15

    I am trying to make a serial port terminal and i have succesfully made it except for some problems that i am facing. i have a button pressing which the terminal starts and the data from the serial port start to get displayed on the textbox. when i press the button again the serial port closes. Also i have put the code to read from the serial port in a timer with a time of 1 millisecond. So it automatically works like a loop and the data can be displayed continuously. Case 1. when i try reading from the serial port using

    _SerialPort.ReadLine ()

    what happens is that the data is getting displayed perfectly, but i am not able to press the button again to close the serial port, also i cant even close the application. I would have to use the task manager to kill the process. Case 2. when i try reading from the serial port using

    _SerialPort.ReadExisting ()

    what happens is that the earlier issue is resolved, but the data that is received is not continuous, that is some values are not recieved.

    C# help

  • closing second form without closing first form
    A alfie max15

    thanx for the reply...

    secondform.close();

    this code worked

    C# help question

  • closing second form without closing first form
    A alfie max15

    I have two forms. there is a button in the first form, when clicked will open up the second form. Now what i want is that when i click the button on the first form again i want the second form to close. i am aware of the code for opening a second form from the primary.

    secondform.show();

    but can any one help me in providing with the code for closing this second form??? the second form should close and the first form should stay open.

    C# help question

  • Need to make a GUI for reading from serial Port. And using Multiple forms
    A alfie max15

    Thanx... I did that... Now what i specifically want is that when i press the button the form2 should pop up but at the same time the form1 should close. i tried... In form1

    private void Start_Click (object sender, EventArgs e)
    {
    secondForm.Show();
    this.Close ();

        }
    

    but what happened was that the form2 will open and both form 1 and form2 get closed. i thought only form1 will get close as i had called this from form1

    C# com hardware help question

  • Need to make a GUI for reading from serial Port. And using Multiple forms
    A alfie max15

    I am doing a project in which i am trying to read the data that is being sent from my microcontroller to the PC through serial port. I am ok with the serial part (i guess)... I was thinking of making it like, first when i run the program a gui would pop up asking user to select the COM port and other details like handshake, parity, baud rate, etc. And after setting all that when the user presses the START button the current form should close and another form should pop up showing the data being read from the port continously. Is that possible to create multiple forms ???? If possible please help me in doing so....

    C# com hardware help question

  • Serial Port communication in C#
    A alfie max15

    thanx.... that did the trick...:)

    C# help csharp visual-studio
  • Login

  • Don't have an account? Register

  • Login or register to search.
  • First post
    Last post
0
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups