Click here to Skip to main content
15,907,183 members
Home / Discussions / C#
   

C#

 
GeneralRe: Is it possible to make this routine automatic? Pin
But_Im_a_Lady22-Jul-08 20:30
But_Im_a_Lady22-Jul-08 20:30 
AnswerRe: Is it possible to make this routine automatic? Pin
Michael Dausmann22-Jul-08 5:34
Michael Dausmann22-Jul-08 5:34 
GeneralRe: Is it possible to make this routine automatic? Pin
But_Im_a_Lady22-Jul-08 20:33
But_Im_a_Lady22-Jul-08 20:33 
Question.net 2.0 windows - treeview Pin
arkiboys22-Jul-08 4:36
arkiboys22-Jul-08 4:36 
AnswerRe: .net 2.0 windows - treeview Pin
half-life22-Jul-08 7:57
half-life22-Jul-08 7:57 
GeneralRe: .net 2.0 windows - treeview Pin
arkiboys22-Jul-08 10:21
arkiboys22-Jul-08 10:21 
GeneralRe: .net 2.0 windows - treeview Pin
half-life23-Jul-08 10:24
half-life23-Jul-08 10:24 
GeneralRe: .net 2.0 windows - treeview Pin
arkiboys23-Jul-08 10:52
arkiboys23-Jul-08 10:52 
GeneralRe: .net 2.0 windows - treeview Pin
half-life23-Jul-08 19:33
half-life23-Jul-08 19:33 
QuestionControl Hardware through Software Pin
thund3rstruck22-Jul-08 4:00
thund3rstruck22-Jul-08 4:00 
AnswerRe: Control Hardware through Software Pin
stancrm22-Jul-08 4:05
stancrm22-Jul-08 4:05 
GeneralRe: Control Hardware through Software Pin
thund3rstruck22-Jul-08 4:15
thund3rstruck22-Jul-08 4:15 
GeneralRe: Control Hardware through Software Pin
Luc Pattyn22-Jul-08 4:22
sitebuilderLuc Pattyn22-Jul-08 4:22 
GeneralRe: Control Hardware through Software Pin
thund3rstruck22-Jul-08 4:43
thund3rstruck22-Jul-08 4:43 
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
Alex@UEA22-Jul-08 5:02 
QuestionHow to remove a AddIn from VStudio 2008 Pin
Tomerland22-Jul-08 3:37
Tomerland22-Jul-08 3:37 
AnswerRe: How to remove a AddIn from VStudio 2008 Pin
Rob Siklos22-Jul-08 8:30
Rob Siklos22-Jul-08 8:30 
QuestionProblem in Remoting Pin
stancrm22-Jul-08 3:33
stancrm22-Jul-08 3:33 
QuestionLogConsole? Recommendations? Pin
tkrn22-Jul-08 2:36
tkrn22-Jul-08 2:36 
AnswerRe: LogConsole? Recommendations? Pin
Mustafa Ismail Mustafa22-Jul-08 3:05
Mustafa Ismail Mustafa22-Jul-08 3:05 
AnswerRe: LogConsole? Recommendations? Pin
wurzel_cidermaker22-Jul-08 4:29
wurzel_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
TheComputerMan22-Jul-08 2:13 
AnswerRe: Event handling in C# Pin
Mustafa Ismail Mustafa22-Jul-08 2:31
Mustafa Ismail Mustafa22-Jul-08 2:31 
AnswerRe: Event handling in C# Pin
Dave Doknjas22-Jul-08 13:20
Dave Doknjas22-Jul-08 13:20 

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.