I'm using WinForms. I have a button in this form. When the button is clicked I want the program to print a specific file every time i click on it.
My Problem is: My code does not print the specific file in my computer. It prints out a blank document.
Example: Button click prints document "C:\image.jpg" all the time.
private void btn_Print_Click (object sender, EventArgs e)
{
printDialog1.AllowSomePages = true;
printDialog1.AllowSelection = true;
printDocument1.PrinterSettings.PrintToFile = true;
if (printDialog1.ShowDialog() == DialogResult.OK)
{
printDialog1.PrinterSettings.PrintFileName = #"C:\\image";
printDocument1.Print();
}
}
private void printDocument1_PrintPage(object sender, System.Drawing.Printing.PrintPageEventArgs e)
{
}
The following code works. You may need to adjust it as needed, but this would be your starting point.
Reference: https://social.msdn.microsoft.com/Forums/windows/en-US/f83aff78-44c1-465c-86b4-9e4e5a2d97e2/how-to-print-files-stored-at-your-local-hard-drive-in-c?forum=winforms
Make sure you have:
using System.Drawing;
using System.Drawing.Printing;
here it is:
private void button1_Click(object sender, EventArgs e)
{
using (PrintDocument pd = new PrintDocument())
{
if (printDialog1.ShowDialog() == DialogResult.OK)
{
string filePath = #"C:\image.JPG";
pd.OriginAtMargins = true;
pd.PrintPage += pd_PrintPage;
pd.DocumentName = filePath;
pd.Print();
pd.PrintPage -= pd_PrintPage;
}
}
}
public void pd_PrintPage(object sender, PrintPageEventArgs e)
{
string labelPath = ((PrintDocument)sender).DocumentName;
e.Graphics.DrawImage(new Bitmap(labelPath), 0, 0);
}
Related
I have a program that creates a list of hyperlinks to the files i search for. I can click the resulting hyperlink and the PDF opens. I would like to also have it make a copy of the pdf on my C: also without dialog. The source of the files is from the network. FileSearchButton_Click will search a directory for files with the content that match my search string.
aLinkLabel_LinkClicked is where I feel the copy action should be done
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.DirectoryServices;
using System.Drawing;
using System.IO;
using System.Linq;
using System.Text;
using System.Windows.Forms;
namespace FindFilesBasedOnText
{
public partial class FileSearcherBasedOnSpecificText : Form
{
SmartTextBox DirectoryTextBox = new SmartTextBox();
SmartTextBox SearchTextBox = new SmartTextBox();
SmartButton SearchButton = new SmartButton();
SmartButton FileSearchButton = new SmartButton();
public FileSearcherBasedOnSpecificText()
{
InitializeComponent();
DirectoryTextBox.Location = new Point(70, 12);
DirectoryTextBox.ForeColor = Color.Black;
DirectoryTextBox.ForeColor = Color.Black;
this.Controls.Add(DirectoryTextBox);
SearchTextBox.Location = new Point(70, 43);
//SearchTextBox.Size = new Size(478, 20);
this.Controls.Add(SearchTextBox);
SearchButton.Location = new Point(526, 12);
SearchButton.Size = new Size(160, 23);
SearchButton.Text = "Search Directory";
SearchButton.TabStop = false;
SearchButton.Click += SearchButton_Click;
this.Controls.Add(SearchButton);
FileSearchButton.Location = new Point(526, 43);
FileSearchButton.Size = new Size(160, 23);
FileSearchButton.Text = "Search file based-on text";
FileSearchButton.TabStop = false;
FileSearchButton.Click += FileSearchButton_Click;
this.Controls.Add(FileSearchButton);
listBox1.AllowDrop = true;
listBox1.DragDrop += listBox1_DragDrop;
listBox1.DragEnter += listBox1_DragEnter;
listBox1.Focus();
}
private void listBox1_DragEnter(object sender, DragEventArgs e)
{
if (e.Data.GetDataPresent(DataFormats.FileDrop)) e.Effect = DragDropEffects.Copy;
}
private void listBox1_DragDrop(object sender, DragEventArgs e)
{
string[] files = (string[])e.Data.GetData(DataFormats.FileDrop);
foreach (string file in files)
listBox1.Items.AddRange(File.ReadAllLines(file));
}
private void SearchButton_Click(object sender, EventArgs e)
{
FolderBrowserDialog folderBrowserDialog = new FolderBrowserDialog();
DialogResult dialogReasult = folderBrowserDialog.ShowDialog();
if(!string.IsNullOrWhiteSpace(folderBrowserDialog.SelectedPath))
{
DirectoryTextBox.Text = folderBrowserDialog.SelectedPath;
}
}
public void FileSearchButton_Click(object sender, EventArgs e)
{
FilesPanel.Controls.Clear();
int i = 0;
int y = 5;
string filesName = string.Empty;
string rootfolder = DirectoryTextBox.Text.Trim();
string[] files = Directory.GetFiles(rootfolder, "*.*", SearchOption.AllDirectories);
foreach (string file in files)
{
try
{
string contents = File.ReadAllText(file);
if(contents.Contains(SearchTextBox.Text.Trim()))
{
i += 1;
LinkLabel aLinkLabel = new LinkLabel();
aLinkLabel.Text = file;
aLinkLabel.Location = new Point(5, y);
aLinkLabel.AutoSize = true;
aLinkLabel.BorderStyle = BorderStyle.None;
aLinkLabel.LinkBehavior = LinkBehavior.NeverUnderline;
aLinkLabel.ActiveLinkColor = Color.White;
aLinkLabel.LinkColor = Color.White;
aLinkLabel.BackColor = Color.Transparent;
aLinkLabel.VisitedLinkColor = Color.Red;
aLinkLabel.Links.Add(0, file.ToString().Length, file);
aLinkLabel.LinkClicked += aLinkLabel_LinkClicked;
FilesPanel.Controls.Add(aLinkLabel);
y += aLinkLabel.Height + 5;
}
else
{ // This shows DONE after each Search
LinkLabel aLinkLabel = new LinkLabel();
aLinkLabel.Font = new Font("", 12);
aLinkLabel.ActiveLinkColor = Color.White;
aLinkLabel.LinkColor = Color.White;
aLinkLabel.BackColor = Color.Transparent;
aLinkLabel.Text = "DONE";
FilesPanel.Controls.Add(aLinkLabel);
}
}
catch (Exception ex)
{
Console.WriteLine(ex.Message);
}
}
}
void aLinkLabel_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e)
{
LinkLabel lnk = new LinkLabel();
lnk = (LinkLabel)sender;
lnk.Links[lnk.Links.IndexOf(e.Link)].Visited = true;
System.Diagnostics.Process.Start(e.Link.LinkData.ToString());
//Create a directory if not exist for the file to be copied into
if (!System.IO.Directory.Exists(#"C:\Temp\RoHS_Docs"))
{
System.IO.Directory.CreateDirectory(#"C:\Temp\RoHS_Docs");
}
//Perform the file copy action on click
string CopyDestinationPath = #"C:\Temp\RoHS_Docs\";
System.IO.File.Copy(WHAT????, CopyDestinationPath, true);
}
private void FileSearcherBasedOnSpecificText_Load(object sender, EventArgs e)
{
}
private void pictureBox1_Click(object sender, EventArgs e)
{
FilesPanel.Controls.Clear();
}
private void label3_Click(object sender, EventArgs e)
{
}
private void listBox1_SelectedIndexChanged(object sender, EventArgs e)
{
SearchTextBox.Text = listBox1.SelectedItem.ToString();
}
private void label4_Click(object sender, EventArgs e)
{
}
private void progressBar1_Click(object sender, EventArgs e)
{
}
}
}
I have a textbox in my WinForm and when I type the password in, its hidden because:
private void textBoxPWMain2_TextChanged(object sender, EventArgs e)
{
textBoxPWMain2.UseSystemPasswordChar = true;
}
is it possible to add here a button, and while the button is pressed, the password show normal and when I stop pressing the button, the password will hide again?
Maybe this? (Don't forget to subscribe to these events)
private void button2_MouseDown(object sender, EventArgs e)
{
textBoxPWMain2.UseSystemPasswordChar = false;
}
private void button2_MouseUp(object sender, EventArgs e)
{
textBoxPWMain2.UseSystemPasswordChar = true;
}
I have a solution now, I wanted something like a eye button, when you press it down the password shows, when you stop pressing, the password hides again.
Solution
First I added a pictureBox with Eye Icon and added this pictureBox to my password textbox and set Passwort textbox to .UseSystemPasswordChar
public Form1
{
textBoxPW.Controls.Add(pictureBoxEye);
pictureBoxEye.Location = new Point(95,0);
pictureBoxEye.BackColor = Color.Transparent;
textBoxPW.UseSystemPasswordChar = true;
//Subscribe to Event
pictureBoxPW.MouseDown += new MouseEventHandler(pictureBoxPW_MouseDown);
pictureBoxPW.MouseUp += new MouseEventHandler(pictureBoxPW_MouseUp);
}
Added the Mouse_Down/Up Event
private void pictureBoxEye_MouseDown(object sender, MouseEventArgs e)
{
textBoxPW.UseSystemPasswordChar = false;
}
private void pictureBoxEye_MouseUp(object sender, MouseEventArgs e)
{
textBoxPW.UseSystemPasswordChar = true;
}
This works fine for me! Thank you guys !!
Adding a bit change details to ispiro's answer
public void button1_MouseDown(object sender, EventArgs e)
{
textBox1.PasswordChar = '\0';
textBox1.UseSystemPasswordChar = false;
}
public void button1_MouseUp(object sender, EventArgs e)
{
textBox1.PasswordChar = '*';
textBox1.UseSystemPasswordChar = true;
}
Before:-
After :-
Is there a reason you set the UseSystemPasswordChar in the TextChanged event?
If you can set the property in the Initialize() method or in the constructor you can implement the following events for your button:
private void button1_MouseDown(object sender, MouseEventArgs e)
{
textBoxPWMain2.UseSystemPasswordChar = false;
}
private void button1_MouseUp(object sender, MouseEventArgs e)
{
textBoxPWMain2.UseSystemPasswordChar = true;
}
I created an app for my dad. It's just a simple dictation program. The thing is when he installed it on his computer it stalled and said the general access denied error.
The first time it gave the error I used SaveFileDialog sfd = new SaveFileDialog() then added the usually 'if statement" to make sure the dialog was ok. However the app had an access file denied.
I did the same thing with Environment.GetFolder and it installed on his computer to the location and ran fine. However, when I use the saveFileDialog1 and openFileDialog1 out of the tool box it does not save or open a txt document.
It works on my laptop and not his. Could this be due to an error in the code vs his computer. Also what is the correct way to use the Environement.GetFolder with the SaveFileDialog.
I can also post the full code to the program if needed.
private void lblOpenFile_Click(object sender, EventArgs e)
{
OpenFileDialog open = new OpenFileDialog();
open.Title = "Open File";
open.Filter = "Text Files (*txt) | *.txt";
if (open.ShowDialog() == DialogResult.OK)
{
StreamReader read = new StreamReader(File.OpenRead(open.FileName));
txtTextBox.Text = read.ReadToEnd();
read.Dispose();
}
}
private void lblSaveFile_Click(object sender, EventArgs e)
{
SaveFileDialog save = new SaveFileDialog();
save.Title = "Save File";
save.Filter = "Text Files (*txt) | *.txt";
if (save.ShowDialog() == DialogResult.OK)
{
StreamWriter write = new StreamWriter(File.Create(save.FileName));
write.Write(txtTextBox.Text);
write.Dispose();
}
}
This is the Enviroment i used on my screen recorder. i when i click save it brings up a dialog box i put in the file name press save and it does nothing. It saves the file but not as i specified. So i am trying to merge the above and below codes. The above code does not grant access however the below does
string OutputPath;
OutputPath = Environment.GetFolderPath(Environment.SpecialFolder.MyVideos) + #"\\IvanSoft Desktop Recorder" + saveFileDialog1;
private void saveFileDialog1_FileOk(object sender, CancelEventArgs e)
{
string fileName = saveFileDialog1.FileName;
fileName = "Tutorial";
}
the whole code to the program
using System;
using System.Drawing;
using System.Windows.Forms;
using System.IO;
using System.Speech.Recognition;
using System.Threading;
namespace AGM_Speech
{
public partial class Form1 : Form
{
public SpeechRecognitionEngine recognizer;
public Grammar grammar;
public Thread RecThread;
public Boolean RecognizerState = true;
public Form1()
{
InitializeComponent();
}
private void lblAbout_Click(object sender, EventArgs e)
{
this.Hide();
About about = new About();
about.Show();
}
private void Form1_Load(object sender, EventArgs e)
{
GrammarBuilder builder = new GrammarBuilder();
builder.AppendDictation();
grammar = new Grammar(builder);
recognizer = new SpeechRecognitionEngine();
recognizer.LoadGrammarAsync(grammar);
recognizer.SetInputToDefaultAudioDevice();
recognizer.SpeechRecognized += new EventHandler<SpeechRecognizedEventArgs>(recognizer_SpeechRecognized);
RecognizerState = true;
RecThread = new Thread(new ThreadStart(RecThreadFunction));
RecThread.Start();
}
private void recognizer_SpeechRecognized(object sender, SpeechRecognizedEventArgs e)
{
if (!RecognizerState)
return;
this.Invoke((MethodInvoker)delegate
{
txtTextBox.Text += (e.Result.Text.ToLower() + " ");
txtTextBox.SelectionStart = txtTextBox.Text.Length - 0;
txtTextBox.SelectionLength = 0;
});
}
public void RecThreadFunction()
{
while (true)
{
try
{
recognizer.RecognizeAsync();
}
catch
{
}
}
}
private void lblStartSpeech_Click(object sender, EventArgs e)
{
RecognizerState = true;
}
private void lblStopSpeech_Click(object sender, EventArgs e)
{
RecognizerState = false;
}
private void Form1_FormClosing(object sender, FormClosingEventArgs e)
{
RecThread.Abort();
RecThread = null;
grammar = null;
recognizer.UnloadAllGrammars();
recognizer.Dispose();
}
private void lblOpenFile_Click(object sender, EventArgs e)
{
string open = Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments);
StreamReader reader = new StreamReader(Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments));
}
private void lblSaveFile_Click(object sender, EventArgs e)
{
SaveFileDialog save = new SaveFileDialog();
save.Title = "Save File";
save.Filter = "Text Files (*txt) | *.txt";
if (save.ShowDialog() == DialogResult.OK)
{
StreamWriter write = new StreamWriter(File.Create(save.FileName));
write.Write(txtTextBox.Text);
write.Dispose();
}
}
private void txtSearch_Click(object sender, EventArgs e)
{
txtSearch.Clear();
lblGo_Click(null, null);
}
private void txtSearch_KeyPress(object sender, KeyPressEventArgs e)
{
if (e.KeyChar == (char)ConsoleKey.Enter)
{
lblGo_Click(null, null);
}
}
private void lblGo_Click(object sender, EventArgs e)
{
int index = 0;
String temp = txtTextBox.Text;
txtTextBox.Text = "";
txtTextBox.Text = temp;
while (index <= txtTextBox.Text.LastIndexOf(txtSearch.Text))
{
txtTextBox.Find(txtSearch.Text, index, txtTextBox.TextLength, RichTextBoxFinds.None);
txtTextBox.SelectionColor = Color.YellowGreen;
index = txtTextBox.Text.IndexOf(txtSearch.Text, index) + 1;
}
}
}
}
It's hard to say where you're failing, because there isn't much in the way of try/catch or logging.
Can you use this instead, and paste the stack trace that shows in the Message Box?
private string fileOutputLocation { get; set; }
private void lblSaveFile_Click(object sender, EventArgs e)
{
bool fileSelected = false;
Try(() =>
{
SaveFileDialog save = new SaveFileDialog();
save.Title = "Save File";
save.Filter = "Text Files (*txt) | *.txt";
save.InitialDirectory = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.MyVideos), "IvanSoft Desktop Recorder");
if (save.ShowDialog() == DialogResult.OK)
{
fileOutputLocation = save.FileName;
fileSelected = true;
}
});
if (fileSelected)
{
bool fileSaved = SaveFile();
MessageBox.Show("File saved successfully: " + fileSaved.ToString());
}
}
private bool SaveFile()
{
TryDeleteFile();
bool fileSaved = false;
Try(()=>
{
File.WriteAllText(fileOutputLocation, txtTextBox.Text);
fileSaved = true;
});
return fileSaved;
}
private void TryDeleteFile()
{
Try(()=>
{
if (File.Exists(fileOutputLocation))
{
File.Delete(fileOutputLocation);
}
});
}
private void Try(Action action)
{
try
{
action();
}
catch (Exception e)
{
MessageBox.Show(string.Format("The following exception was thrown:\r\n{0}\r\n\r\nFile path: {1}", e.ToString(), fileOutputLocation));
}
}
With this, plus the events logged to the Windows Event Viewer (Start>Run>Eventvwr>Security), we should be able to tell you what the problem is.
Lastly, if you're just providing an executable to run, you should check the properties of the file to ensure it's not blocked in Windows.
I have been working on a manager application for a Minecraft server, when I run my program, the console shows and disappears, if I run it manually, it runs without and problems.
Batch file code:
java -Xmx1024M -jar craftbukkit-1.7.2-R0.3.jar -o false
My full code (MessageBoxes are in Polish, becouse im from Poland, but later i will add support for other languages):
using System;
using System.IO;
using System.Windows.Forms;
using System.Diagnostics;
namespace WindowsFormsApplication1
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
public Process server;
private Boolean runServer()
{
if (!File.Exists(textBox2.Text))
{
MessageBox.Show("Brak określonej ścieżki dostępu! (" + textBox2.Text + ")", "Błąd", MessageBoxButtons.OK, MessageBoxIcon.Error);
return false;
}
Process process = new Process
{
StartInfo =
{
FileName = textBox2.Text,
//Arguments = textBox3.Text,
UseShellExecute = false,
RedirectStandardOutput = true,
CreateNoWindow = false,
}
};
process.OutputDataReceived += new DataReceivedEventHandler(server_outputDataReceived);
process.ErrorDataReceived += new DataReceivedEventHandler(server_outputDataReceived);
server = process;
if (process.Start())
return true;
else
{
MessageBox.Show("Nie można włączyć serwera!", "Błąd", MessageBoxButtons.OK, MessageBoxIcon.Error);
return false;
}
}
private String ReadFile(String filename, int line)
{
StreamReader reader = new StreamReader(filename);
for (int i = 0; i < line; i++)
{
reader.ReadLine();
}
return reader.ReadLine();
}
private void ReloadOPs()
{
if (!File.Exists(textBox1.Text))
{
MessageBox.Show("Sciezka dostępu do pliku z listą graczy posiadających OP nie istnieje! (" + textBox1.Text + ")", "Błąd", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
tabControl1.SelectedTab = tabPageOptions;
textBox1.SelectAll();
return;
}
String line = ReadFile(textBox1.Text, 0);
comboBox1.Items.Clear();
for (int i = 1; i < File.ReadAllLines(textBox1.Text).Length; i++)
{
if (!String.IsNullOrWhiteSpace(ReadFile(textBox1.Text, i)))
{
comboBox1.Items.Add(line);
line = ReadFile(textBox1.Text, i);
}
}
MessageBox.Show("Lista graczy z OP, została odświeżona.");
}
// OPs combobox (OPs)
private void comboBox1_SelectedIndexChanged(object sender, EventArgs e)
{
groupBox1.Text = comboBox1.SelectedItem.ToString();
groupBox1.Visible = true;
}
private void Form1_Load(object sender, EventArgs e)
{
textBox1.Text = Application.StartupPath.ToString() + #"\ops.txt";
ReloadOPs();
}
// Reload OPs button (OPs)
private void button1_Click(object sender, EventArgs e)
{
ReloadOPs();
}
// Save button (Options)
private void button4_Click(object sender, EventArgs e)
{
}
private void server_outputDataReceived(object sender, DataReceivedEventArgs e)
{
addConsoleMessage(e.Data.ToString(), true);
}
// Run server button (Menu)
private void button5_Click(object sender, EventArgs e)
{
if (!runServer())
return;
server.BeginOutputReadLine();
button6.Enabled = true;
}
// Stop server button (Menu)
private void button6_Click(object sender, EventArgs e)
{
if(!server.HasExited)
server.Kill();
button6.Enabled = false;
}
private void addConsoleMessage(String message, Boolean refresh)
{
listBox1.Items.Add(message);
if (refresh)
listBox1.Refresh();
}
}
}
My problem is that program crashes becouse InvaildOperationException was unhandled (listBox1.Items.Add(message) in addConsoleMessage).
External error information: Invalid operation between threads: the control 'listBox1' is accessed from a thread other than the thread it was created.
You cannot update UI form background thread. Try this
WPF
private void server_outputDataReceived(object sender, DataReceivedEventArgs e)
{
Dispatcher.CurrentDispatcher.Invoke(DispatcherPriority.Normal, () =>
{
addConsoleMessage(e.Data.ToString(), true);
});
}
Update
In WinForms the Invoke/BeginInvoke methods are directly on the control objects as you can see from the docs of System.Windows.Forms.Control. So you'd have listBox1.BeginInvoke(...) for example.
I'm doing a project on serial port.. but after i changed my serial comm port into combo box selection, i cant seems to transmit anything data out. here's my codes:
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.IO.Ports;
namespace XSP
{
public partial class Form1 : Form
{
string RxString;
byte[] buffer = Encoding.UTF8.GetBytes("RxString");
public Form1()
{
InitializeComponent();
this.Load += Form1_Load;
serialPort1.DataReceived += new SerialDataReceivedEventHandler(serialPort1_DataReceived);
Console.ReadLine();
}
void Form1_Load(object sender, EventArgs e)
{
var serialPort1 = SerialPort.GetPortNames();
cbCommPorts.DataSource = serialPort1;
}
public static byte[] ConvertToBinary(string str)
{
System.Text.ASCIIEncoding encoding = new System.Text.ASCIIEncoding();
return encoding.GetBytes(str);
}
private void btnOpen_Click(object sender, EventArgs e)
{
if (cbCommPorts.SelectedIndex > -1)
{
MessageBox.Show(String.Format("You selected port '{0}'", cbCommPorts.SelectedItem));
Connect(cbCommPorts.SelectedItem.ToString());
}
else
{
MessageBox.Show("Please select a port first");
}
}
private void Connect(string portName)
{
var serialPort1 = new SerialPort(portName);
if (!serialPort1.IsOpen)
{
serialPort1.BaudRate = 115200;
serialPort1.Open();
btnTransmit.Enabled = true;
btn2.Enabled = true;
btn3.Enabled = true;
btnOpen.Enabled = false;
btnClose.Enabled = true;
}
}
private void btnTransmit_Click(object sender, EventArgs e)
{
if (serialPort1.IsOpen)
{
string value = "12345";
serialPort1.Write(value);
}
else serialPort1.Close();
}
private void txtReceive_KeyPress(object sender, KeyPressEventArgs e)
{
if (serialPort1.IsOpen) return;
char[] buff = new char[1];
buff[0] = e.KeyChar;
serialPort1.Write(buff, 0, 1);
e.Handled = true;
}
private void DisplayText(object sender, EventArgs e)
{
txtReceive.AppendText(RxString);
}
private void serialPort1_DataReceived
(object sender, System.IO.Ports.SerialDataReceivedEventArgs e)
{
RxString = serialPort1.ReadExisting();
this.Invoke(new EventHandler(DisplayText));
}
private void btnOpenFile_Click(object sender, EventArgs e)
{
OpenFileDialog openFileDialog1 = new OpenFileDialog();
openFileDialog1.InitialDirectory = "c:\\";
openFileDialog1.Filter = "txt files (*.txt)|*.txt|All files (*.*)|*.*";
openFileDialog1.FilterIndex = 2;
openFileDialog1.RestoreDirectory = true;
if (openFileDialog1.ShowDialog() == DialogResult.OK)
{
System.IO.StreamReader sr = new
System.IO.StreamReader(openFileDialog1.FileName);
MessageBox.Show(sr.ReadToEnd());
sr.Close();
}
}
private void btnExit_Click(object sender, EventArgs e)
{
Application.Exit();
}
private void btnClose_Click(object sender, EventArgs e)
{
serialPort1.Close();
btnOpen.Enabled = true;
btnClose.Enabled = false;
btnTransmit.Enabled = false;
btn2.Enabled = false;
btn3.Enabled = false;
}
}
}
Can someone help me to point out where my error lies in? Thanks
There are several options possible here, but we need more information to tackle this problem. To start off, make sure you are actually sending data. to do this try a breakpoint on the if statement above where you send the data. And step into the code using F10 and see whether you are actually sending any data.
If you are sending data, your code runs fine and check the receiver application. check baudrates etc...