[Gtk-sharp-list] Gtk# TextView and Scrolling Text

countcb count.cb at gmx.net
Thu Jun 5 04:16:10 EDT 2008



Emfor wrote:
> 
> Hi there,
> I'm fighting with TextView widget. Everything is fine except that when I
> load text to it and move cursor in it - the coursor can go out of view
> (TextView doesn't scroll). I tried many examples with using TextIter and
> TextMark and ScrollToMark function, bu it simply doesn't work.
> Can anyone please tell me what am I doing wrong? 
> 
> -- 
> Best regards,
> Emfor
> 


Hi.
You have to add your TextView to a ScrolledWindow widget and then add this
ScrolledWindow to the window/dialog you want the TextView to be displayed
in.

Below is a small test program which demostrates a srolling TextView.
Christopher.

------

using Gtk;
using Gdk;

namespace GtkTest
{
	class Program
	{
		public static void Main (string[] args)
		{
			Application.Init ();
			Gtk.Window win = new TestWindow();
			win.ShowAll();
			Application.Run ();
		}
	}
}

namespace GtkTest
{
	class TestWindow : Gtk.Window
	{
		public TestWindow() : base(Gtk.WindowType.Toplevel)
		{
			this.DeleteEvent += this.OnDeleteEvent; 	
			this.SetSizeRequest(800, 600);

			ScrolledWindow scrolledWindow = new ScrolledWindow();
			TextView yourTextView = new TextView();
			
			scrolledWindow.Add(yourTextView);			
			this.Add(scrolledWindow);
		}		
		
		private void OnDeleteEvent(object sender, DeleteEventArgs a)
		{
			System.Console.WriteLine("onDelete");
			Application.Quit();
			a.RetVal = true;
		}		
			
	}
}
-- 
View this message in context: http://www.nabble.com/Gtk--TextView-and-Scrolling-Text-tp17653284p17664545.html
Sent from the Mono - Gtk# mailing list archive at Nabble.com.



More information about the Gtk-sharp-list mailing list