logo
Welcome Guest! To enable all features please Login or Register.

Notification

Icon
Error

New Topic Post Reply
Options
Go to last post Go to first unread
Guest  
#1 Posted : Friday, February 19, 2016 12:08:56 AM(UTC)
Quote
Guest

Rank: Guest

Groups: Guests
Joined: 1/5/2016(UTC)
Posts: 162

Was thanked: 5 time(s) in 5 post(s)
Hi,

is it possible to set text in the search bar in toolbox dynamically ?

In Patagames.Pdf.Net.Controls.WinForms.ToolBars.PdfToolStripSearch()

Thanks
Paul Rayman  
#2 Posted : Friday, February 19, 2016 1:25:00 AM(UTC)
Quote
Paul Rayman

Rank: Administration

Groups: Administrators
Joined: 1/5/2016(UTC)
Posts: 1,138

Thanks: 10 times
Was thanked: 133 time(s) in 130 post(s)
Well... I can suggest a ugly hack
Code:

(pdfToolStripSearch1.Items["btnSearchBar"] as ToolStripControlHost).Control.Controls[0].Controls[0].Controls[0].Controls[0].Text = "document";


or you can make some changes in source code:

change the visibility of the following classes to public instead internal.
internal class ToolStripSearchBar
internal class SearchBar

in ToolStripSearchBar change the internal SearchBar property to public

in PdfToolStripSearch write somthing like this:
Code:

public SearchBar SearchBar
{
	get
	{
		return (this.Items["btnSearchBar"] as ToolStripSearchBar).Control as SearchBar;
	}
}


and now you can use it like this:
Code:

pdfToolStripSearch1.SearchBar.SearchText = "document";


Guest  
#3 Posted : Sunday, February 21, 2016 11:40:55 PM(UTC)
Quote
Guest

Rank: Guest

Groups: Guests
Joined: 1/5/2016(UTC)
Posts: 162

Was thanked: 5 time(s) in 5 post(s)
thanks for your answer.

When i use your first method i have an error : (System.NullReferenceException)


at Patagames.Pdf.Net.Controls.WinForms.ToolBars.PdfToolStripSearch.StopSearch()
at Patagames.Pdf.Net.Controls.WinForms.ToolBars.PdfToolStripSearch.StartSearch(SearchBar sb, String searchText)
at Patagames.Pdf.Net.Controls.WinForms.ToolBars.PdfToolStripSearch.OnNeedSearch(ToolStripControlHost item, String searchText)
at Patagames.Pdf.Net.Controls.WinForms.ToolBars.PdfToolStripSearch.SearchBar_NeedSearch(Object sender, EventArgs e)
at Patagames.Pdf.Net.Controls.WinForms.ToolBars.SearchBar.OnSearch()
at Patagames.Pdf.Net.Controls.WinForms.ToolBars.SearchBar._onsearchTimer_Tick(Object sender, EventArgs e)
at System.Windows.Forms.Timer.OnTick(EventArgs e)
at System.Windows.Forms.Timer.TimerNativeWindow.WndProc(Message& m)
at System.Windows.Forms.NativeWindow.DebuggableCallback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)
at MS.Win32.UnsafeNativeMethods.DispatchMessage(MSG& msg)
at System.Windows.Threading.Dispatcher.PushFrameImpl(DispatcherFrame frame)
at System.Windows.Threading.Dispatcher.PushFrame(DispatcherFrame frame)
at System.Windows.Application.RunDispatcher(Object ignore)
at System.Windows.Application.RunInternal(Window window)
at System.Windows.Application.Run(Window window)
at System.Windows.Application.Run()
at Planche.App.Main() in C:\Users\9305924K\Desktop\Planche main\Master\Planche\Planche\obj\Debug\App.g.cs:line 0
at System.AppDomain._nExecuteAssembly(RuntimeAssembly assembly, String[] args)
at System.AppDomain.ExecuteAssembly(String assemblyFile, Evidence assemblySecurity, String[] args)
at Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly()
at System.Threading.ThreadHelper.ThreadStart_Context(Object state)
at System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
at System.Threading.ThreadHelper.ThreadStart()
Paul Rayman  
#4 Posted : Monday, February 22, 2016 12:30:48 AM(UTC)
Quote
Paul Rayman

Rank: Administration

Groups: Administrators
Joined: 1/5/2016(UTC)
Posts: 1,138

Thanks: 10 times
Was thanked: 133 time(s) in 130 post(s)
At what point do you call this code?
May be at this moment the toolbar does not initialized yet?

Edited by user Monday, February 22, 2016 12:32:18 AM(UTC)  | Reason: Not specified

Guest  
#5 Posted : Monday, February 22, 2016 12:45:27 AM(UTC)
Quote
Guest

Rank: Guest

Groups: Guests
Joined: 1/5/2016(UTC)
Posts: 162

Was thanked: 5 time(s) in 5 post(s)
I call in the constructor when i get this error.

Code:
        public ToolsFrm(Patagames.Pdf.Net.Controls.WinForms.PdfViewer viewer)
        {
            Patagames.Pdf.Net.PdfCommon.Initialize();
            this.PdfViewer = viewer;
      
            InitializeComponent();
            (pdfToolStripSearch1.Items["btnSearchBar"] as ToolStripControlHost).Control.Controls[0].Controls[0].Controls[0].Controls[0].Text = "document";
            cpt++;
           
        }
Paul Rayman  
#6 Posted : Monday, February 22, 2016 5:47:19 AM(UTC)
Quote
Paul Rayman

Rank: Administration

Groups: Administrators
Joined: 1/5/2016(UTC)
Posts: 1,138

Thanks: 10 times
Was thanked: 133 time(s) in 130 post(s)
Try to move it into Form.Shown event handler
Code:

private void Form1_Shown(Object sender, EventArgs e)
{
    pdfToolStripSearch1.Items["btnSearchBar"] as ToolStripControlHost).Control.Controls[0].Controls[0].Controls[0].Controls[0].Text = "document";
}
Guest  
#7 Posted : Monday, February 22, 2016 6:13:29 AM(UTC)
Quote
Guest

Rank: Guest

Groups: Guests
Joined: 1/5/2016(UTC)
Posts: 162

Was thanked: 5 time(s) in 5 post(s)
THANKS A LOT !
Quick Reply Show Quick Reply
Users browsing this topic
Guest
New Topic Post Reply
Forum Jump  
You can post new topics in this forum.
You can reply to topics in this forum.
You can delete your posts in this forum.
You can edit your posts in this forum.
You cannot create polls in this forum.
You can vote in polls in this forum.