Button.BackColor & Button.Image Property Issue..
HI Friends,
I am facing one more prob.
In my Windows application, I want to SET & GET BUTTON'S BACKCOLOR PROPERTY.
Ofcourse, I can GET backcolor property & save it in DATABASE,
But I CAN'T SET BACKCOLOR PROPERTY AT RUNTIME.
can you please tell me how I can SET BACKCOLOR PROPERTY AT RUNTIME [BY USING CODE]
thank you for your kind help,
-nanc
Re: Button.BackColor GET & SET Property Issue..
here's how I do it for all of the button controls in a group
VB Code:
For Each ctl As Control In StrategyBuildergrp.Controls
If TypeOf (ctl) Is Button Then
CType(ctl, Button).BackColor = BUTTON_COLOR
End If
Next
of course if you are changing the color of a single button, then use
VB Code:
button1.backcolor = system.drawing.color.<somecolor>
HTH
kevin
Re: Button.BackColor GET & SET Property Issue..
Hi Friend,
Thank you for your kind help.
As you suggested for ASSIGNING backcolor to button, here is code you suggested.
---------------------VISUAL BASIC CODE-------------------
button1.backcolor = system.drawing.color.<somecolor>
-----------------------------------------------------------
my prob. is <somecolor> value will come from database which is in STRING format. And thats the only reason it dosen't work, how can I convert STRING in to COLOR ENABLED OBJECT ????
I hope, I explained well my prob.
thank you,
- nanc
Re: Button.BackColor GET & SET Property Issue..
provided the string is a valid color name you can use something like
VB Code:
Dim MyColor As String = "Gray"
Button1.BackColor = Color.FromName(MyColor)
HTH
kevin
how to get Button.Image name
Hi Friend,
thank you for your help, it works.
but I got caught in another tiny matter,
HOW CAN I GET BUTTON.IMAGE NAME AT RUNTIME.
I am hopeful that you know the answer.
thank you,
-nanc
Re: Button.BackColor & Button.Image Property Issue..
Hi friends,
I think, I didn't explain my prob.
In my app., I creat COMMAND BUTTON at runtime and assign/SET property values.
I also retrive/GET property values like BUTTON.TEXT, BUTTON.BACKCOLOR, and BUTTON.IMAGE...
I can't get BUTTON.IMAGE name in text or any other form. I want to store BUTTON.IMAGE NAME IN DATABASE IN TEXT FORM.
can you pls help me out getting such matter done..
thank you,
-nanc
Re: Button.BackColor & Button.Image Property Issue..
I'm not sure you can get the image name from the button.image per se. If you set the image in your code, then maybe you can also set the button tag proerty to your image name.
kevin
Re: Button.BackColor & Button.Image Property Issue..
Its true that I can get image name from button tag property while loading button.
but, user may change image runtime, so how code can find that user has changed image & which one is the latest image.
???
little confused.
may be your little help makes a big result here.
-nanc
Re: Button.BackColor & Button.Image Property Issue..
Is it in your code that the user will change the image? If so, then when he/she changes the image then you can reset the tag property at the same time. It still may be possible to get the image name at run time, but I just don't know how.
kevin