C# scrollbar op canvas

Status
Niet open voor verdere reacties.

ecross

Gebruiker
Lid geworden
4 mrt 2009
Berichten
638
hallo allemaal,

ik maak gebruik van een splitcontainer met aan de ene kant
een textvak waarin mensen wat tekst kunnen typen en aan de andere kant een canvas waar die tekst verschijnt.
als mensen veel tekst typen komt er in het textvak een scrollbar, maar in het canvas niet, het canvas is namemelijk even groot als het paneel van de splitcontainer waar hij inzit.
ik heb 2 oplossingen bedacht:
1. is het mogenlijk om een scrollbar in het canvas te maken?
2. kan ik het canvas even hoog als de tekst maken die erin ziet en dat in het paneel een scrollbar maken?

alvast bedankt, ecross
 
ik ben een beginner en ik gebruik visual c#, kun je nog wat meer uitleggen?

dit is (een deel) van de code die ik nu heb:
[CPP]
private void scMain_Panel2_Paint(object sender, PaintEventArgs e)
{
System.Drawing.Graphics formGraphics = e.Graphics;
string drawString = txtInput.Text;
int x = 0;
int x2 = (int)Convert.ToDouble(tsdDepth.Text);
int y = 0;
float size = (float)Convert.ToDouble(tsdSize.Text);
FontStyle style = FontStyle.Regular;
System.Drawing.Font drawFont = new Font("Arial", size, style);
if (tsbBold.CheckState == CheckState.Checked)
{
style = FontStyle.Bold;
drawFont = new Font(drawFont, drawFont.Style | style);
}
if (tsbUnderline.CheckState == CheckState.Checked)
{
style = FontStyle.Underline;
drawFont = new Font(drawFont, drawFont.Style | style);
}
if (tsbItalic.CheckState == CheckState.Checked)
{
style = FontStyle.Italic;
drawFont = new Font(drawFont, drawFont.Style | style);
}
Color color_red = Color.FromArgb(100, 255, 0, 0);
Color color_cyan = Color.FromArgb(100, 0, 255, 255);
Color color_green = Color.FromArgb(100, 0, 255, 0);
System.Drawing.SolidBrush brush_red = new System.Drawing.SolidBrush(color_red);
System.Drawing.SolidBrush brush_2 = new System.Drawing.SolidBrush(color_cyan);
if (tsbBrilrc.Checked)
{
brush_2 = new System.Drawing.SolidBrush(color_cyan);
}
else
{
brush_2 = new System.Drawing.SolidBrush(color_green);
}
int width = scMain.Panel2.Width;
int height = scMain.Panel2.Height*2;
Rectangle rechthoek1 = new Rectangle(x, y, width, height);
Rectangle rechthoek2 = new Rectangle(x2, y, width, height);
formGraphics.DrawString(drawString, drawFont, brush_red, rechthoek1);
formGraphics.DrawString(drawString, drawFont, brush_2, rechthoek2);
drawFont.Dispose();
brush_red.Dispose();
brush_2.Dispose();
formGraphics.Dispose();
}
[/CPP]

kun je hier wat mee?
 
Status
Niet open voor verdere reacties.
Terug
Bovenaan Onderaan