By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
446,383 Members | 2,063 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 446,383 IT Pros & Developers. It's quick & easy.

RightToLeft.Inherit

P: n/a
I wrote a component using class library wizard. In my component i want to in
order to RightToLeft property do some works.
I can find out if user set this property to Yes or No, But if He/She set it
to Inherit I must examine its parent RightToLeft property(if i`m wrong please
tell me) but in this component that inherits from
System.ComponentModel.Component, How can i find parent???
In UserControls we can simply use Parent property but in this kind of
components, how we can find parent.

Thanks in advance.
Nov 16 '05 #1
Share this Question
Share on Google+
6 Replies


P: n/a
Mohammad,
To the best of my knowledge, at run time, there is no 'Inherit' value, it
can only be Yes/No.
What I actually mean is that any control/component that has its RightToLeft
set to inherit at design time will inherit its parent direction somewhere in
its runtime lifecycle and before you can see it.

again, this is just based on my past experience and not facts.

Picho
"Mohammad-Reza" <Mo**********@discussions.microsoft.com> wrote in message
news:D5**********************************@microsof t.com...
I wrote a component using class library wizard. In my component i want to
in
order to RightToLeft property do some works.
I can find out if user set this property to Yes or No, But if He/She set
it
to Inherit I must examine its parent RightToLeft property(if i`m wrong
please
tell me) but in this component that inherits from
System.ComponentModel.Component, How can i find parent???
In UserControls we can simply use Parent property but in this kind of
components, how we can find parent.

Thanks in advance.

Nov 16 '05 #2

P: n/a
Dear Picho
I wrote an if statement that checks if the my control RightToLeft property
is set to yes or no, but when ever i set main form(Parent of my control)
RightToLeft to Yes and my component to Inherit no one of if statements works.

"Picho" wrote:
Mohammad,
To the best of my knowledge, at run time, there is no 'Inherit' value, it
can only be Yes/No.
What I actually mean is that any control/component that has its RightToLeft
set to inherit at design time will inherit its parent direction somewhere in
its runtime lifecycle and before you can see it.

again, this is just based on my past experience and not facts.

Picho
"Mohammad-Reza" <Mo**********@discussions.microsoft.com> wrote in message
news:D5**********************************@microsof t.com...
I wrote a component using class library wizard. In my component i want to
in
order to RightToLeft property do some works.
I can find out if user set this property to Yes or No, But if He/She set
it
to Inherit I must examine its parent RightToLeft property(if i`m wrong
please
tell me) but in this component that inherits from
System.ComponentModel.Component, How can i find parent???
In UserControls we can simply use Parent property but in this kind of
components, how we can find parent.

Thanks in advance.


Nov 16 '05 #3

P: n/a
I see.
I probably misunderstood you.

A Component has no Internal RightToLeft support. I thought you were talking
about a Control/UserControl.
If that is the case, you should implement a Parent property yourself that
implements direction control (any Control object), and then sign to its
RightToLeftChanged event.

Picho
"Mohammad-Reza" <Mo**********@discussions.microsoft.com> wrote in message
news:23**********************************@microsof t.com...
Dear Picho
I wrote an if statement that checks if the my control RightToLeft property
is set to yes or no, but when ever i set main form(Parent of my control)
RightToLeft to Yes and my component to Inherit no one of if statements
works.

"Picho" wrote:
Mohammad,
To the best of my knowledge, at run time, there is no 'Inherit' value, it
can only be Yes/No.
What I actually mean is that any control/component that has its
RightToLeft
set to inherit at design time will inherit its parent direction somewhere
in
its runtime lifecycle and before you can see it.

again, this is just based on my past experience and not facts.

Picho
"Mohammad-Reza" <Mo**********@discussions.microsoft.com> wrote in message
news:D5**********************************@microsof t.com...
>I wrote a component using class library wizard. In my component i want
>to
>in
> order to RightToLeft property do some works.
> I can find out if user set this property to Yes or No, But if He/She
> set
> it
> to Inherit I must examine its parent RightToLeft property(if i`m wrong
> please
> tell me) but in this component that inherits from
> System.ComponentModel.Component, How can i find parent???
> In UserControls we can simply use Parent property but in this kind of
> components, how we can find parent.
>
> Thanks in advance.


Nov 16 '05 #4

P: n/a
Ok thanx, but how can I implement a parent property?

"Picho" wrote:
I see.
I probably misunderstood you.

A Component has no Internal RightToLeft support. I thought you were talking
about a Control/UserControl.
If that is the case, you should implement a Parent property yourself that
implements direction control (any Control object), and then sign to its
RightToLeftChanged event.

Picho
"Mohammad-Reza" <Mo**********@discussions.microsoft.com> wrote in message
news:23**********************************@microsof t.com...
Dear Picho
I wrote an if statement that checks if the my control RightToLeft property
is set to yes or no, but when ever i set main form(Parent of my control)
RightToLeft to Yes and my component to Inherit no one of if statements
works.

"Picho" wrote:
Mohammad,
To the best of my knowledge, at run time, there is no 'Inherit' value, it
can only be Yes/No.
What I actually mean is that any control/component that has its
RightToLeft
set to inherit at design time will inherit its parent direction somewhere
in
its runtime lifecycle and before you can see it.

again, this is just based on my past experience and not facts.

Picho
"Mohammad-Reza" <Mo**********@discussions.microsoft.com> wrote in message
news:D5**********************************@microsof t.com...
>I wrote a component using class library wizard. In my component i want
>to
>in
> order to RightToLeft property do some works.
> I can find out if user set this property to Yes or No, But if He/She
> set
> it
> to Inherit I must examine its parent RightToLeft property(if i`m wrong
> please
> tell me) but in this component that inherits from
> System.ComponentModel.Component, How can i find parent???
> In UserControls we can simply use Parent property but in this kind of
> components, how we can find parent.
>
> Thanks in advance.


Nov 16 '05 #5

P: n/a
this is a simple almost complete example:

// Code start:
using System;

namespace ParentPropertyExample
{
public class RTLComponent : System.ComponentModel.Component
{
private System.Windows.Forms.Control _parent;
private System.Windows.Forms.RightToLeft _rightToLeft;
private bool _inheritRightToLeft;

public RTLComponent()
{
}
public RTLComponent(System.Windows.Forms.Control parent)
{
this.Parent = parent;
}

public System.Windows.Forms.Control Parent
{
get
{
return _parent;
}
set
{
if (_parent==value)
return;

if (_parent!=null)
_parent.RightToLeftChanged-=new
EventHandler(this.ParentRightToLeftChanged);

_parent = value;
_parent.RightToLeftChanged+=new
EventHandler(this.ParentRightToLeftChanged);

if (this.DesignMode)
return;

if (!_inheritRightToLeft)
return;

if (this.Parent==null)
this.RightToLeft = System.Windows.Forms.RightToLeft.No;
else
this.RightToLeft = this.Parent.RightToLeft;
}
}

public System.Windows.Forms.RightToLeft RightToLeft
{
get
{
return _rightToLeft;
}
set
{
if (this.DesignMode)
{
if (value==System.Windows.Forms.RightToLeft.Inherit)
_inheritRightToLeft = true;
else
_inheritRightToLeft = false;
}

_rightToLeft = value;
}
}

private void ParentRightToLeftChanged(object sender, EventArgs e)
{
if (this.DesignMode)
return;

if (!_inheritRightToLeft)
return;

if (this.Parent==null)
this.RightToLeft = System.Windows.Forms.RightToLeft.No;
else
this.RightToLeft = this.Parent.RightToLeft;
}
}
}
// code end

talk to me again if it is not clear - have no time to explain right now -
sorry,

Picho

"Mohammad-Reza" <Mo**********@discussions.microsoft.com> wrote in message
news:07**********************************@microsof t.com...
Ok thanx, but how can I implement a parent property?

"Picho" wrote:
I see.
I probably misunderstood you.

A Component has no Internal RightToLeft support. I thought you were
talking
about a Control/UserControl.
If that is the case, you should implement a Parent property yourself that
implements direction control (any Control object), and then sign to its
RightToLeftChanged event.

Picho
"Mohammad-Reza" <Mo**********@discussions.microsoft.com> wrote in message
news:23**********************************@microsof t.com...
> Dear Picho
> I wrote an if statement that checks if the my control RightToLeft
> property
> is set to yes or no, but when ever i set main form(Parent of my
> control)
> RightToLeft to Yes and my component to Inherit no one of if statements
> works.
>
> "Picho" wrote:
>
>> Mohammad,
>> To the best of my knowledge, at run time, there is no 'Inherit' value,
>> it
>> can only be Yes/No.
>> What I actually mean is that any control/component that has its
>> RightToLeft
>> set to inherit at design time will inherit its parent direction
>> somewhere
>> in
>> its runtime lifecycle and before you can see it.
>>
>> again, this is just based on my past experience and not facts.
>>
>> Picho
>> "Mohammad-Reza" <Mo**********@discussions.microsoft.com> wrote in
>> message
>> news:D5**********************************@microsof t.com...
>> >I wrote a component using class library wizard. In my component i
>> >want
>> >to
>> >in
>> > order to RightToLeft property do some works.
>> > I can find out if user set this property to Yes or No, But if He/She
>> > set
>> > it
>> > to Inherit I must examine its parent RightToLeft property(if i`m
>> > wrong
>> > please
>> > tell me) but in this component that inherits from
>> > System.ComponentModel.Component, How can i find parent???
>> > In UserControls we can simply use Parent property but in this kind
>> > of
>> > components, how we can find parent.
>> >
>> > Thanks in advance.
>>
>>
>>


Nov 16 '05 #6

P: n/a
Thank you very much Picho

"Picho" wrote:
this is a simple almost complete example:

// Code start:
using System;

namespace ParentPropertyExample
{
public class RTLComponent : System.ComponentModel.Component
{
private System.Windows.Forms.Control _parent;
private System.Windows.Forms.RightToLeft _rightToLeft;
private bool _inheritRightToLeft;

public RTLComponent()
{
}
public RTLComponent(System.Windows.Forms.Control parent)
{
this.Parent = parent;
}

public System.Windows.Forms.Control Parent
{
get
{
return _parent;
}
set
{
if (_parent==value)
return;

if (_parent!=null)
_parent.RightToLeftChanged-=new
EventHandler(this.ParentRightToLeftChanged);

_parent = value;
_parent.RightToLeftChanged+=new
EventHandler(this.ParentRightToLeftChanged);

if (this.DesignMode)
return;

if (!_inheritRightToLeft)
return;

if (this.Parent==null)
this.RightToLeft = System.Windows.Forms.RightToLeft.No;
else
this.RightToLeft = this.Parent.RightToLeft;
}
}

public System.Windows.Forms.RightToLeft RightToLeft
{
get
{
return _rightToLeft;
}
set
{
if (this.DesignMode)
{
if (value==System.Windows.Forms.RightToLeft.Inherit)
_inheritRightToLeft = true;
else
_inheritRightToLeft = false;
}

_rightToLeft = value;
}
}

private void ParentRightToLeftChanged(object sender, EventArgs e)
{
if (this.DesignMode)
return;

if (!_inheritRightToLeft)
return;

if (this.Parent==null)
this.RightToLeft = System.Windows.Forms.RightToLeft.No;
else
this.RightToLeft = this.Parent.RightToLeft;
}
}
}
// code end

talk to me again if it is not clear - have no time to explain right now -
sorry,

Picho

"Mohammad-Reza" <Mo**********@discussions.microsoft.com> wrote in message
news:07**********************************@microsof t.com...
Ok thanx, but how can I implement a parent property?

"Picho" wrote:
I see.
I probably misunderstood you.

A Component has no Internal RightToLeft support. I thought you were
talking
about a Control/UserControl.
If that is the case, you should implement a Parent property yourself that
implements direction control (any Control object), and then sign to its
RightToLeftChanged event.

Picho
"Mohammad-Reza" <Mo**********@discussions.microsoft.com> wrote in message
news:23**********************************@microsof t.com...
> Dear Picho
> I wrote an if statement that checks if the my control RightToLeft
> property
> is set to yes or no, but when ever i set main form(Parent of my
> control)
> RightToLeft to Yes and my component to Inherit no one of if statements
> works.
>
> "Picho" wrote:
>
>> Mohammad,
>> To the best of my knowledge, at run time, there is no 'Inherit' value,
>> it
>> can only be Yes/No.
>> What I actually mean is that any control/component that has its
>> RightToLeft
>> set to inherit at design time will inherit its parent direction
>> somewhere
>> in
>> its runtime lifecycle and before you can see it.
>>
>> again, this is just based on my past experience and not facts.
>>
>> Picho
>> "Mohammad-Reza" <Mo**********@discussions.microsoft.com> wrote in
>> message
>> news:D5**********************************@microsof t.com...
>> >I wrote a component using class library wizard. In my component i
>> >want
>> >to
>> >in
>> > order to RightToLeft property do some works.
>> > I can find out if user set this property to Yes or No, But if He/She
>> > set
>> > it
>> > to Inherit I must examine its parent RightToLeft property(if i`m
>> > wrong
>> > please
>> > tell me) but in this component that inherits from
>> > System.ComponentModel.Component, How can i find parent???
>> > In UserControls we can simply use Parent property but in this kind
>> > of
>> > components, how we can find parent.
>> >
>> > Thanks in advance.
>>
>>
>>


Nov 16 '05 #7

This discussion thread is closed

Replies have been disabled for this discussion.