Click here to Skip to main content
15,898,222 members
Home / Discussions / C#
   

C#

 
AnswerRe: FileSystemWatcher Question Pin
Dimitri Witkowski13-Feb-10 0:05
Dimitri Witkowski13-Feb-10 0:05 
GeneralRe: FileSystemWatcher Question Pin
#realJSOP13-Feb-10 0:18
professional#realJSOP13-Feb-10 0:18 
AnswerRe: FileSystemWatcher Question Pin
Abhinav S13-Feb-10 0:07
Abhinav S13-Feb-10 0:07 
GeneralRe: FileSystemWatcher Question Pin
#realJSOP13-Feb-10 0:17
professional#realJSOP13-Feb-10 0:17 
QuestionHow to set ToolTip to ToolStripButton? Pin
arichikato12-Feb-10 18:44
arichikato12-Feb-10 18:44 
AnswerRe: How to set ToolTip to ToolStripButton? Pin
Saksida Bojan12-Feb-10 19:46
Saksida Bojan12-Feb-10 19:46 
AnswerMessage Closed Pin
12-Feb-10 20:43
stancrm12-Feb-10 20:43 
GeneralRe: How to set ToolTip to ToolStripButton? Pin
arichikato13-Feb-10 7:47
arichikato13-Feb-10 7:47 
thanks to all.
everithing works.
code looks like this:

public void TranslateForm(Control control, ToolTip toolTip)
{
string textProperty = null;
Type formType = control.GetType();
ResourceManager res = new ResourceManager(formType);

RecurControls(control, res, toolTip);

FieldInfo[] formFields = formType.GetFields(BindingFlags.NonPublic | BindingFlags.DeclaredOnly | BindingFlags.Instance);
foreach (FieldInfo fieldInfo in formFields)
{
// некий код, задающий локализацию для ToolTip'ов
object field = fieldInfo.GetValue(control);

PropertyInfo propertyInfo = fieldInfo.FieldType.GetProperty("Text");
//Нет свойства Text
if (propertyInfo != null)
{
//Проверка на Menu
if (field is Menu)
{
Menu menu = (Menu)fieldInfo.GetValue(control);
foreach (MenuItem item in menu.MenuItems)
{
foreach (FieldInfo innerFieldInfo in formFields)
if (innerFieldInfo.FieldType == typeof(MenuItem) && innerFieldInfo.GetValue(control) == item)
{
string resourceText = (string)res.GetObject(innerFieldInfo.Name + ".Text");
item.Text = resourceText;
break;
}
}
}

try
{
if ((fieldInfo.Name != "tbDjvuPageNumber")
&& (fieldInfo.Name != "lblDjvuPagesCount"))
{
textProperty = (string)res.GetObject(fieldInfo.Name + '.' + propertyInfo.Name);
if (textProperty != null && textProperty != "" && field != null)
propertyInfo.SetValue(field, textProperty, null);
}
}
catch { }

propertyInfo = fieldInfo.FieldType.GetProperty("ToolTipText");
if (propertyInfo != null)
{
try
{
textProperty = (string)res.GetObject(fieldInfo.Name + '.' + propertyInfo.Name);
if (textProperty != null && textProperty != "" && field != null)
propertyInfo.SetValue(field, textProperty, null);
}
catch { }
}
}
}
if (control is Import)
control.Text = (string)res.GetObject("$this.Text");
}


private void RecurControls(System.Windows.Forms.Control parent, System.Resources.ResourceManager resources, System.Windows.Forms.ToolTip toolTip)
{
foreach (Control control in parent.Controls)
{
string toolTipText;
control.SuspendLayout();

try
{
toolTipText = (string)resources.GetObject(control.Name + ".ToolTip");
if (toolTipText != null && toolTipText != "")
toolTip.SetToolTip(control, toolTipText);
}
catch
{
}

if (control.Controls.Count > 0)
RecurControls(control, resources, toolTip);

control.ResumeLayout();
}
}
QuestionInaccessible due to its protection level [modified] Pin
ASPnoob12-Feb-10 16:38
ASPnoob12-Feb-10 16:38 
AnswerRe: Inaccessible due to its protection level Pin
Wes Aday12-Feb-10 17:14
professionalWes Aday12-Feb-10 17:14 
GeneralRe: Inaccessible due to its protection level Pin
ASPnoob12-Feb-10 17:25
ASPnoob12-Feb-10 17:25 
GeneralRe: Inaccessible due to its protection level Pin
Wes Aday12-Feb-10 17:37
professionalWes Aday12-Feb-10 17:37 
AnswerRe: Inaccessible due to its protection level Pin
DaveyM6912-Feb-10 22:56
professionalDaveyM6912-Feb-10 22:56 
AnswerRe: Inaccessible due to its protection level Pin
Luc Pattyn13-Feb-10 1:26
sitebuilderLuc Pattyn13-Feb-10 1:26 
QuestionCall a .aspx web-form from Microsoft CRM 4 Pin
quercus12-Feb-10 12:56
quercus12-Feb-10 12:56 
QuestionTTF file format Pin
sduhd12-Feb-10 12:13
sduhd12-Feb-10 12:13 
AnswerRe: TTF file format Pin
harold aptroot12-Feb-10 12:52
harold aptroot12-Feb-10 12:52 
QuestionWindows service & Timers Pin
koleraba12-Feb-10 10:06
koleraba12-Feb-10 10:06 
AnswerRe: Windows service & Timers Pin
PIEBALDconsult12-Feb-10 10:38
mvePIEBALDconsult12-Feb-10 10:38 
GeneralRe: Windows service & Timers Pin
koleraba12-Feb-10 11:01
koleraba12-Feb-10 11:01 
GeneralRe: Windows service & Timers Pin
PIEBALDconsult12-Feb-10 14:09
mvePIEBALDconsult12-Feb-10 14:09 
GeneralRe: Windows service & Timers Pin
koleraba12-Feb-10 22:36
koleraba12-Feb-10 22:36 
GeneralRe: Windows service & Timers Pin
PIEBALDconsult13-Feb-10 3:20
mvePIEBALDconsult13-Feb-10 3:20 
AnswerRe: Windows service & Timers Pin
DaveyM6912-Feb-10 10:47
professionalDaveyM6912-Feb-10 10:47 
GeneralRe: Windows service & Timers Pin
koleraba12-Feb-10 11:04
koleraba12-Feb-10 11:04 

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.