Im creating a simple application to search and manipulate a database.I want to add a text box to search a name but I want the textbox to be eyecandy.I dont want the traditional textbox.Instead I would like something like this
Can anyone please tell me how to do this.I dont know how to make custom controls.Please help.
Thank you
This is as far as I got. Has not been fully tested.
Thank you so much Master of Orion.But can you teach me how to use this in a windows form?I am new to programming and have no idea how to implement this on a vb form.
Thank you so much Master of Orion.But can you teach me how to use this in a windows form?I am new to programming and have no idea how to implement this on a vb form.
Thank you
Add his file to your project (right click the project in the solution explorer on the right, select add then select existing file), then build your project (from the build menu at the top of visual studio), then add the control to your form(s), it's at the very top with a purple "gear" icon of the toolbox on the left.
Currently using VS 2015 Enterprise on Win10 Enterprise x64.
This is as far as I got. Has not been fully tested.
Thank you master of Orion.I added your control via existing item and got it to working.I have got the textbox with rounded ends but I dont get the search image infront of the textbox.Can you please help to fix this issue
Add his file to your project (right click the project in the solution explorer on the right, select add then select existing file), then build your project (from the build menu at the top of visual studio), then add the control to your form(s), it's at the very top with a purple "gear" icon of the toolbox on the left.
Thanks juggalobrotha..I managed to do that but the textbox does not show the search image on it.Can you take a look please
Thanks juggalobrotha..I managed to do that but the textbox does not show the search image on it.Can you take a look please
Add an ImageList (from the toolbox) to your form. Add a spyglass image to it, then on ForumAccountant's TextBox control set it's ImageList property to your form's ImageList and then it should show the image like in his screenshot picture.
It might be easier to add an Image property to the control and an ImageAlignment property (being Left or Right) so that you just set a single image and tell it which side to display on.
Edit: Oh, set the ImageKey property to the actual image that's in the ImageList too. Here's an example project.
Last edited by JuggaloBrotha; Dec 20th, 2011 at 09:29 PM.
Currently using VS 2015 Enterprise on Win10 Enterprise x64.
Add an ImageList (from the toolbox) to your form. Add a spyglass image to it, then on ForumAccountant's TextBox control set it's ImageList property to your form's ImageList and then it should show the image like in his screenshot picture.
It might be easier to add an Image property to the control and an ImageAlignment property (being Left or Right) so that you just set a single image and tell it which side to display on.
Edit: Oh, set the ImageKey property to the actual image that's in the ImageList too. Here's an example project.
Thank you so much Juggalobrotha...I got it to working.Is there a way to add the image to the control itself so I can use the control in every form.Otherwise I would have to add an imagelist to every form I create wouldnt I?
And also I cant change the font in the textbox.Desperately need help on this also.
Thanks in advance
Last edited by chathu1234; Dec 22nd, 2011 at 01:17 AM.
Well ultimately it uses an Image variable from the ImageList when rendering things, so it shouldn't be all that hard to just expose the Image property and you could do away with the ImageList properties altogether if you wanted to.
Changing the Font should be as easy as exposing the underlaying TextBox's Font property. I see that he has a class that's used to overlay the actual textbox control and it's simply a matter of exposing those properties through the ImageTextBox class.
I might have time this evening to poke around with it and see about getting the Font, Fore & Back color properties to be available in his control and I'll post it here.
Currently using VS 2015 Enterprise on Win10 Enterprise x64.
I wasn't able to finish this, but I did get it to just be an Image property instead of using an ImageList and an ImageIndex property to have an image showing, but when you actually set it to an image, it crashes and I'm really at a loss to why, the error message shown (at design time, in the designer) doesn't help because the Paint event that uses the Image property already checks that it's not a null reference:
It has a problem with this block of code:
Code:
If Me.Image IsNot Nothing Then
e.Graphics.DrawImage(Me.Image, Me.GetImageRectangle(), 0, 0, 16, 16, GraphicsUnit.Pixel)
End If
I also added the Font, ForeColor and BackColor properties too, though if you change the font (right now) to a larger font then you have to re-size the control on the form yourself to accomodate that. I don't know how to have the control re-size itself vertically like a normal textbox does when you change the font size (and the TB is not allowing multiple lines of course).
Other than those 2 issues, it's mostly done for you. If I get the chance next week I might try and finish it, but I suspect ForumAccountant will get to it before me anyways.
Currently using VS 2015 Enterprise on Win10 Enterprise x64.
I wasn't able to finish this, but I did get it to just be an Image property instead of using an ImageList and an ImageIndex property to have an image showing, but when you actually set it to an image, it crashes and I'm really at a loss to why, the error message shown (at design time, in the designer) doesn't help because the Paint event that uses the Image property already checks that it's not a null reference:
It has a problem with this block of code:
Code:
If Me.Image IsNot Nothing Then
e.Graphics.DrawImage(Me.Image, Me.GetImageRectangle(), 0, 0, 16, 16, GraphicsUnit.Pixel)
End If
I also added the Font, ForeColor and BackColor properties too, though if you change the font (right now) to a larger font then you have to re-size the control on the form yourself to accomodate that. I don't know how to have the control re-size itself vertically like a normal textbox does when you change the font size (and the TB is not allowing multiple lines of course).
Other than those 2 issues, it's mostly done for you. If I get the chance next week I might try and finish it, but I suspect ForumAccountant will get to it before me anyways.
Thank you so much JuggaloBrotha for taking your valuable time and coming up with a solution.But unfortunately there is something wrong.When I change the font it displays the changes.But when I build the solution it automatically reverts back to the original font.