C-sharp Das aktive von 2 Scintillas ausgeben
Hallo ihr Administratoren,
ich habe auf 2 panels jeweils ein Scintilla. Um z.B. Text in das aktive Scintilla einzufügen, habe ich mir eine Methode gebastelt:
Aber jetzt gibt es das Problem, manchmal funktioniert es, manchmal nicht. Wie kann man das lösen? Gibt es eine andere, bessere Methode?
ich habe auf 2 panels jeweils ein Scintilla. Um z.B. Text in das aktive Scintilla einzufügen, habe ich mir eine Methode gebastelt:
private Scintilla GetCurrentScintilla()
{
try
{
if (c1active())
return this.panel9.Controls as Scintilla;
else if (c2active())
return this.panel13.Controls as Scintilla;
else
return null;
}
catch(Exception ex)
{
MessageBox.Show(ex.Message);
return null;
}
}
private bool c1active()
{
try
{
Scintilla c = this.panel9.Controls as Scintilla;
if (c != null)
{
if (c.Focused)
return true;
else
return false;
}
else
return false;
}
catch(Exception e)
{
MessageBox.Show(e.Message);
return false;
}
}
private bool c2active()
{
try
{
Scintilla c = this.panel13.Controls as Scintilla;
if (c != null)
{
if (c.Focused)
return true;
else
return false;
}
else
return false;
}
catch (Exception e)
{
MessageBox.Show(e.Message);
return false;
}
}
Aber jetzt gibt es das Problem, manchmal funktioniert es, manchmal nicht. Wie kann man das lösen? Gibt es eine andere, bessere Methode?
Please also mark the comments that contributed to the solution of the article
Content-Key: 334553
Url: https://administrator.de/contentid/334553
Printed on: April 19, 2024 at 23:04 o'clock
3 Comments
Latest comment
Was für Gorillas?
Vielleicht gehst du mal in den städtischen Zoo, dann weißt du sicher welcher gerade die Banane schwingt .
Vielleicht gehst du mal in den städtischen Zoo, dann weißt du sicher welcher gerade die Banane schwingt .
Dann nehm doch einfach das Enter-Event und setze eine public var mit dem aktiven Scintilla
namespace WindowsFormsApplication1 {
public partial class Form1 : Form {
public Form1() {
InitializeComponent();
}
public ScintillaNET.Scintilla ActiveScintilla = null;
private void sc1_Enter(object sender, EventArgs e) {
ActiveScintilla = sc1;
}
private void sc2_Enter(object sender, EventArgs e) {
ActiveScintilla = sc2;
}
}
}