灰显选项卡控件显示屏上的文字? [英] Gray-out the text on the tab control display?

查看:74
本文介绍了灰显选项卡控件显示屏上的文字?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想控制进入一个或多个选项卡

我已根据设置规则设置我的Tab控件。是否有人知道如何使文本变灰,以便用户看到他们无法访问该特定标签?

我尝试设置enabled = false对于给定的选项卡,
但它似乎只在表单汇编部分工作(
,如果我在表单通过
函数加载后执行,它不会似乎工作),并这样做
禁用选项卡上的控件,但不会灰显选项卡显示本身的文本。

谢谢

K



解决方案

我假设您在加载表单之前不知道启用/禁用?如果

这样一个构造函数通过tabindex会工作正常。


我也假设你已经尝试设置
$ b的启用属性$ b你想要禁用的特殊标签页...


这是真的吗?


Shane

" ; KMiller" <一个******* @ discussions.microsoft.com>在留言中写道

news:05 **************************** @ phx.gbl ... < blockquote class =post_quotes>我想控制进入一个或多个选项卡

我已根据设置规则设置我的Tab控件。是否有人知道如何使文本变灰,以便用户看到他们无法访问该特定标签?

我尝试设置enabled = false对于给定的选项卡,


它似乎只在表单汇编部分工作(
,如果我在表单加载后执行一个
功能,它似乎没有工作),并且这样做
禁用选项卡上的控件,但不会灰显选项卡显示本身的文本。 />
谢谢

K



在表格组装时,我不要知道。

然而,此后不久(在加载过程中),

我知道他们是否有权访问

特定标签。正是在这个时候,我正试图用b $ b禁用(灰显)标签文本,但没有任何作用。


我'我已经尝试将

选项卡的enabled属性设置为false,但这样做对标签文本显示没有任何影响,

并且用户无法知道他们没有有权访问

到其他选项卡然后点击它并找出

没有任何效果,因为所有控件都被禁用了
。以这种方式离开功能是不够的,不符合规格。

-----原始消息-----
我假设您在加载表格之前不知道
启用/禁用?如果一个传递tabindex的构造函数可以正常工作。

我还假设您已尝试为要禁用的特定标签页设置启用的
属性...

Shane
KMiller <一个******* @ discussions.microsoft.com>写在
messagenews:05 **************************** @ phx.gbl ...

我想控制进入
标签中的一个或多个

>我已根据设置规则设置了我的Tab控件。
>任何人都知道如何使文本变灰,以便用户
将>看到他们无权访问该特定的
标签? >
>我尝试为给定的选项卡设置enabled = false,


但是

>它似乎只在表单汇编部分
中工作(如果我在表单通过
>函数加载后执行此操作,它似乎无法正常工作),并且这样做
>禁用选项卡上的控件,但不会灰色
out>标签文本显示本身。
>
>谢谢
>
> K





嗨K,


哇,我明白你的意思了。


我以为我也把它固定在了我的应用程序中但我的头衔也没有被禁用。


你可以修复所有权,并且很容易改变字体的颜色。


Private Sub TabControl1_DrawItem(ByVal发送者作为对象,ByVal e As

System.Windows.Forms.DrawItemEventArgs)处理TabControl1.DrawItem

Dim tp As TabPage

Dim layoutrct As New RectangleF(e.Bounds.Left,e.Bounds.Top,

e.Bounds.Width,e.Bounds.Height)

Dim sf As New StringFormat(StringFormatFlags.FitBlackBox)

sf.Alignment = StringAlignment.Center

sf.LineAlignment = StringAlignment.Center


tp = TabControl1.TabPages(e.Index)

如果不是tp.Enabled然后

''由于某种原因没有打印3-d部分 - 试图打印两次

带偏移但没有运气

e.Graphics.DrawString(tp.Text,e.Font,SystemBrushes.ControlLight,

layoutrct)

layoutrct.Offset (2,2)

e.Graphics.DrawString(tp.Text,e.Font,SystemBrushes.ControlDark,

layoutrct)''SolidBrush(e.BackColor), layoutrct)

Else

e.Graphics.DrawString(tp.Text,e.Font,New SolidBrush(e.BackColor),

layoutrct )

结束如果

结束次级


如果未启用项目,则此方法有效。但必须有一个更简单的方法 - 也是

他们甚至不能点击选项卡。


我还没找到如何避免这种情况。


对于简单的事情来说这是一个非常大的痛苦 - 但似乎包含的控制中的大部分都缺乏bacic功能,需要大量的额外编码才能做标准的事情。


我希望你找到答案 - 我也想知道。


Shane

" KMiller" <一个******* @ discussions.microsoft.com>在留言中写道

news:00 **************************** @ phx.gbl ... < blockquote class =post_quotes>在表格组装时,我不知道。
然而,此后不久(在加载过程中),
我知道他们是否有权访问
特定标签。正是在这个时候我试图禁用(灰显)标签文本,但没有任何作用。

我已经尝试将启用的属性设置为对于
选项卡是假的,但这对选项卡文本显示没有任何作用,用户无法知道他们没有访问选项卡,只需点击进入选项卡即可发现
没有任何作用,因为所有控件都被禁用了。以这种方式离开功能是不够的和超出规范。

-----原始消息-----
我假设在加载


启用/禁用的表单之前你不知道?如果

所以传递tabindex的构造函数可以正常工作。

我还假设你已经尝试为


属性class =post_quotes>您想要禁用的特定标签页...

这是真的吗?

Shane
KMiller <一个******* @ discussions.microsoft.com>写在


消息

新闻:05 **************************** @phx.gbl ...

我想控制一个或多个标签的输入>我已根据设置规则设置了我的Tab控件。是>>任何人都知道如何使文本变灰,以便用户将>看到他们无权访问该特定标签? >
>我尝试为给定的标签设置enabled = false,
但是
>它似乎只在表单汇编部分工作(>是,如果我在表单通过
>函数加载后执行它,它似乎没有工作),并且这样做
>禁用选项卡上的控件,但不会灰显>标签文本显示本身。
>
>谢谢
>
> K





I would like to control entry into one or more of the tabs

I have set up on my Tab control based on set rules. Does
anyone know how to grey-out the text so that a user will
see that they do not have access to that particular tab?

I tried setting the enabled = false for the given tab, but it only seems to work in the form assembly section (that
is, if I do it after the form is loaded through a
function, it doesn''t seem to work), and doing that
disables the controls on the tab, but does not grey out
the text of the tab display itself.

Thanks

K



解决方案

I assume you don''t know before loading the form which to enable/disable? If
so a contructor passed a tabindex would work fine.

I also assume that you have tried setting the enabled property for the
particular tab page that you want disabled...

Is this true?

Shane
"KMiller" <an*******@discussions.microsoft.com> wrote in message
news:05****************************@phx.gbl...

I would like to control entry into one or more of the tabs

I have set up on my Tab control based on set rules. Does
anyone know how to grey-out the text so that a user will
see that they do not have access to that particular tab?

I tried setting the enabled = false for the given tab,


but

it only seems to work in the form assembly section (that
is, if I do it after the form is loaded through a
function, it doesn''t seem to work), and doing that
disables the controls on the tab, but does not grey out
the text of the tab display itself.

Thanks

K



At the time the form is assembled, I DO NOT know.
However, shortly thereafter (during the loading process),
I DO know whether they have access or not to the
particular tab. It''s at this time when I''m attempting to
disable (gray-out) the tab text, but nothing works.

I''ve tried setting the enabled property to false for the
tab, but doing that does nothing to the tab text display,
and users have no way of knowing they DO NOT have access
to the tab other then by clicking into it and finding out
that nothing works because all the controls have been
disabled. Leaving the functionality this way is
inadequate and out of spec.

-----Original Message-----
I assume you don''t know before loading the form which to enable/disable? Ifso a contructor passed a tabindex would work fine.

I also assume that you have tried setting the enabled property for theparticular tab page that you want disabled...

Is this true?

Shane
"KMiller" <an*******@discussions.microsoft.com> wrote in messagenews:05****************************@phx.gbl...

I would like to control entry into one or more of the tabs

> I have set up on my Tab control based on set rules. Does > anyone know how to grey-out the text so that a user will > see that they do not have access to that particular tab? >
> I tried setting the enabled = false for the given tab,


but

> it only seems to work in the form assembly section (that > is, if I do it after the form is loaded through a
> function, it doesn''t seem to work), and doing that
> disables the controls on the tab, but does not grey out > the text of the tab display itself.
>
> Thanks
>
> K


.



Hi K,

wow, I see your point.

I thought I had it fixed in my app too but my titles aren''t disabled either.

You can do ownerdrawn fixed and change the color of the font easy enough.

Private Sub TabControl1_DrawItem(ByVal sender As Object, ByVal e As
System.Windows.Forms.DrawItemEventArgs) Handles TabControl1.DrawItem
Dim tp As TabPage
Dim layoutrct As New RectangleF(e.Bounds.Left, e.Bounds.Top,
e.Bounds.Width, e.Bounds.Height)
Dim sf As New StringFormat(StringFormatFlags.FitBlackBox)
sf.Alignment = StringAlignment.Center
sf.LineAlignment = StringAlignment.Center

tp = TabControl1.TabPages(e.Index)
If Not tp.Enabled Then
''for some reason not printing the 3-d part--tried to print twice
with offset but no luck
e.Graphics.DrawString(tp.Text, e.Font, SystemBrushes.ControlLight,
layoutrct)
layoutrct.Offset(2, 2)
e.Graphics.DrawString(tp.Text, e.Font, SystemBrushes.ControlDark,
layoutrct) ''SolidBrush(e.BackColor), layoutrct)
Else
e.Graphics.DrawString(tp.Text, e.Font,New SolidBrush(e.BackColor),
layoutrct)
End If
End Sub

This works if items are not enabled. But there must be an easier way--also
they shouldn''t even be able to click on the tab.

I haven''t found out how to avoid that.

this is a really big pain for something simple--but it seems that most of
the control included are lacking in very bacic features and require lots of
extra coding to just do standard things.

I hope you find an answer--I would also like to know.

Shane
"KMiller" <an*******@discussions.microsoft.com> wrote in message
news:00****************************@phx.gbl...

At the time the form is assembled, I DO NOT know.
However, shortly thereafter (during the loading process),
I DO know whether they have access or not to the
particular tab. It''s at this time when I''m attempting to
disable (gray-out) the tab text, but nothing works.

I''ve tried setting the enabled property to false for the
tab, but doing that does nothing to the tab text display,
and users have no way of knowing they DO NOT have access
to the tab other then by clicking into it and finding out
that nothing works because all the controls have been
disabled. Leaving the functionality this way is
inadequate and out of spec.

-----Original Message-----
I assume you don''t know before loading the form which to


enable/disable? If

so a contructor passed a tabindex would work fine.

I also assume that you have tried setting the enabled


property for the

particular tab page that you want disabled...

Is this true?

Shane
"KMiller" <an*******@discussions.microsoft.com> wrote in


message

news:05****************************@phx.gbl...

I would like to control entry into one or more of the tabs > I have set up on my Tab control based on set rules. Does > anyone know how to grey-out the text so that a user will > see that they do not have access to that particular tab? >
> I tried setting the enabled = false for the given tab,
but
> it only seems to work in the form assembly section (that > is, if I do it after the form is loaded through a
> function, it doesn''t seem to work), and doing that
> disables the controls on the tab, but does not grey out > the text of the tab display itself.
>
> Thanks
>
> K


.



这篇关于灰显选项卡控件显示屏上的文字?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆