Click here to Skip to main content
14,484,540 members
   

C#

 
GeneralRe: Control Hardware through Software Pin
Luc Pattyn22-Jul-08 5:20
sitebuilderLuc Pattyn22-Jul-08 5:20 
AnswerRe: Control Hardware through Software Pin
Alex@UEA22-Jul-08 5:02
MemberAlex@UEA22-Jul-08 5:02 
QuestionHow to remove a AddIn from VStudio 2008 Pin
Tomerland22-Jul-08 3:37
MemberTomerland22-Jul-08 3:37 
AnswerRe: How to remove a AddIn from VStudio 2008 Pin
Rob Siklos22-Jul-08 8:30
MemberRob Siklos22-Jul-08 8:30 
QuestionProblem in Remoting Pin
stancrm22-Jul-08 3:33
Memberstancrm22-Jul-08 3:33 
QuestionLogConsole? Recommendations? Pin
tkrn22-Jul-08 2:36
Membertkrn22-Jul-08 2:36 
AnswerRe: LogConsole? Recommendations? Pin
Mustafa Ismail Mustafa22-Jul-08 3:05
MemberMustafa Ismail Mustafa22-Jul-08 3:05 
AnswerRe: LogConsole? Recommendations? Pin
wurzel_cidermaker22-Jul-08 4:29
Memberwurzel_cidermaker22-Jul-08 4:29 
Here's one way, create a test project with:-

2 Forms (Form1 and DebugWindow)
1 "Logger" class.

Form1 just has 2 buttons on it, 1 to write an entry to the "Logger" class,
the other to "Show" the Debug form.

The DebugWindow form just has a Listbox on it.

The Logger class has a static method which can be called from any class in your project,
which in turn writes an entry in your DebugWindow listbox.

Here's the Form1 class.

<<<
public partial class Form1 : Form
{
DebugWindow dbug;

public Form1()
{
InitializeComponent();
}

private void Form1_Load(object sender, EventArgs e)
{
dbug = new DebugWindow();
dbug.Show();

Logger.DebugWindow = dbug.DebugListBox;
}

private void button1_Click(object sender, EventArgs e)
{
Logger.LogIt(DateTime.Now.ToString("dd MM yyyy HH:mm:ss.fff"));
}

private void button2_Click(object sender, EventArgs e)
{
dbug.Show();
}
}
>>>

Here's the DebugWindow class.

<<<

public partial class DebugWindow : Form
{
private ListBox _debugListbox;

public DebugWindow()
{
InitializeComponent();
}

//
// hide form
//
private void hideToolStripMenuItem_Click(object sender, EventArgs e)
{
this.Hide();
}

//
// Properties
//
public ListBox DebugListBox
{
get { return _debugListbox; }
set { _debugListbox = value; }
}

private void DebugWindow_Load(object sender, EventArgs e)
{
DebugListBox = listBox1;
}
}

>>>

Here's the Logger class.

<<<

class Logger
{

private static ListBox _debugWindow;

//
// Log Message
//
public static void LogIt(string sData)
{
sData = sData.Trim();

UpdateListBox(sData);

}

//
// output to listbox
//
delegate void ListBoxStringAdder(string sInfp);
private static void UpdateListBox(string sInfo)
{
int iLines = 999;

if (DebugWindow.InvokeRequired)
{
ListBoxStringAdder lsa = new ListBoxStringAdder(UpdateListBox);
DebugWindow.Invoke(lsa, new object[] { sInfo });
}
else
{
if (DebugWindow.Items.Count == iLines)
{
DebugWindow.Items.RemoveAt(iLines - 1);

DebugWindow.Items.Insert(0, DateTime.Now.ToString("dd.MM.yyyy HH:mm:ss.fff") + " | " + sInfo);

DebugWindow.SelectedIndex = 0;
}
else
{
DebugWindow.Items.Insert(0, DateTime.Now.ToString("dd.MM.yyyy HH:mm:ss.fff") + " | " + sInfo);

DebugWindow.SelectedIndex = 0;
}
}
}

//
// Properties
//
public static ListBox DebugWindow
{
get { return _debugWindow; }
set { _debugWindow = value; }
}

}

>>>
QuestionEvent handling in C# Pin
TheComputerMan22-Jul-08 2:13
MemberTheComputerMan22-Jul-08 2:13 
AnswerRe: Event handling in C# Pin
Mustafa Ismail Mustafa22-Jul-08 2:31
MemberMustafa Ismail Mustafa22-Jul-08 2:31 
AnswerRe: Event handling in C# Pin
Dave Doknjas22-Jul-08 13:20
MemberDave Doknjas22-Jul-08 13:20 
Questionsocket programming Pin
AlexPizzano22-Jul-08 1:43
MemberAlexPizzano22-Jul-08 1:43 
AnswerRe: socket programming Pin
stancrm22-Jul-08 1:46
Memberstancrm22-Jul-08 1:46 
AnswerRe: socket programming Pin
nelsonpaixao22-Jul-08 13:15
Membernelsonpaixao22-Jul-08 13:15 
QuestionC++ code to access .NET component Pin
Sitaram Sukumar22-Jul-08 1:35
MemberSitaram Sukumar22-Jul-08 1:35 
AnswerRe: C++ code to access .NET component Pin
stancrm22-Jul-08 1:43
Memberstancrm22-Jul-08 1:43 
QuestionGeneral Question of thread Pin
Mogaambo22-Jul-08 1:21
MemberMogaambo22-Jul-08 1:21 
AnswerRe: General Question of thread Pin
N a v a n e e t h22-Jul-08 1:38
MemberN a v a n e e t h22-Jul-08 1:38 
AnswerRe: General Question of thread Pin
Guffa22-Jul-08 2:09
MemberGuffa22-Jul-08 2:09 
QuestionRefreshing DatagridView Pin
Creamboy22-Jul-08 1:16
MemberCreamboy22-Jul-08 1:16 
AnswerRe: Refreshing DatagridView Pin
Mustafa Ismail Mustafa22-Jul-08 2:34
MemberMustafa Ismail Mustafa22-Jul-08 2:34 
AnswerRe: Refreshing DatagridView Pin
nelsonpaixao22-Jul-08 13:22
Membernelsonpaixao22-Jul-08 13:22 
QuestionHow to get RGB color values of web cam image Pin
DC22522-Jul-08 1:14
MemberDC22522-Jul-08 1:14 
AnswerRe: How to get RGB color values of web cam image Pin
Luc Pattyn22-Jul-08 2:23
sitebuilderLuc Pattyn22-Jul-08 2:23 
RantRe: How to get RGB color values of web cam image Pin
Laleen Dharmasena29-Oct-12 17:59
MemberLaleen Dharmasena29-Oct-12 17:59 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.