|
|
i set variable as a bitmap buffer
dim bufferBmp As Bitmap
Dim myfont As Font = New Font(New FontFamily("Arial"), 8, FontStyle.Regular)
when i use drawstring on the bitmap and display it on a picbox
g.DrawString("Start", myfont, mysolidbrush, startdrawx, d)
the output of the string seems like become bolded and unclear, it will never happen when i draw directly on the picturebox, i need to use bitmap buffer due to certain reasons, somebody suggested me set the pixel format of the bmp using Format32bppArgb or Format32bppPArgb.
but i really a beginner in VB.Net, anyone can provide me the sample coding to set the format??
thanks for any help!!
|
|
|
|
|
You might want to try creating your Bitmap object using the Grpahics object of the PicBox.
Dim grPicBox as Graphics = PicBox.CreateGraphics()
Dim bufferBmp As New Bitmap(Width, Height, grPicBox)
This will give your Bitmap the same PixelFormat as the PicBox. The only down side is you have to give the Width and Height of the buffer.
RageInTheMachine9532
|
|
|
|
|
In visual basic .net, for the database concepts
i am in position to operate my transactionsthrough three architecture.
so that i can support the multiuser environment.In this concept i had a diffculity.I need to put my middle tier-datasets as a global.so that while filling the data from database to dataset i can distribute to all the clients acessing the my middle tier.so i can avoid the frequent hitting the database and also i need not to be fill the datasets often.Pls can anyone help me on this.And also suggest me about the idea what i had followed.
Sriram
|
|
|
|
|
See my reply in the ASP.NET[^] forum.
--Colin Mackay--
"In the confrontation between the stream and the rock, the stream always wins - not through strength but perseverance." (H. Jackson Brown)
Enumerators in .NET: See how to customise foreach loops with C#
|
|
|
|
|
How can I with Tabcontrol select or focus any TabPage with code.
I don't know how do this.
Johnny
|
|
|
|
|
You can do this using the SelectedIndex of the TabControl. SelectedIndex will get or set the Index of the currently selected tab. For example, the following code assumes that there is a Button and a TabControl on the form. The Button is used to select the next tab in the TabControl.
Dim currentTab As Integer
Dim highestTab As Integer
Private Sub cbNext_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cbNext.Click
Dim nextTab As Integer = currentTab + 1
If nextTab > highestTab Then
nextTab = 0
End If
TabControl1.SelectedIndex = nextTab
currentTab = TabControl1.SelectedIndex
End Sub
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
currentTab = TabControl1.SelectedIndex
highestTab = TabControl1.TabCount - 1
End Sub
RageInTheMachine9532
|
|
|
|
|
I just want to know ,how can i use this code on TAB select,i have been trying this on Tab select,instead of Button click,in order to get effect this on Tab select ,On which event should i write the code.u can mail me shihab@vatimsolutions.com...Thanxs in advance.
|
|
|
|
|
The code I submitted was an example of how to change the Tab in code. You can use the same code in a different routine if you want. Just the most important part was TabControl1.SelectedIndex = (tab number). The rest was just keeping track of which tab was selected and what the next tab number is.
Using the TabPage.Select method doesn't work the way you would expect it to. The user won't see any change in the tab that is shown if you use that method.
RageInTheMachine9532
|
|
|
|
|
Hi again,
Onwards with my list of woes...
I have a floating panel container which folds away whenever it looses focus or isn't being pointed at with the mouse. When I popup a context menu my panel thinks its time to fold away! Bugger!
If my floating panel contains the focus all is well, but if its not focused, and it just opens because I pointed at it with the mouse, then when I open a context menu from the panel, the system thinks I am no longer pointing at the panel, and its right, because I am pointing at the menu. I need to hold the panel open whilst the menu is being processed. What's the best way to know when the menu has closed, without sticking code in all its menu item click event handlers?
I will know when the menu is first opened, I just don't know how to catch it being closed.
Thanks for reading
Nursey
|
|
|
|
|
Is there a simple straight forward method of persisting properties of child controls which are contained within user controls?
I have a user control which inherits from panel, on that panel is a single text box. The panel user control exposes the text box through a HostedControl property so that the user can set the MultiLine property at designtime. However, that property change is not serialized. It seems that I either have to expose a multiline property on the user control which drives the text box property, or I have to somehow serialize the properties of the text box myself.
Any pointers would be appreciated (ooh, provided there to valid memory locations ).
Just to make this abolutely clear. When I add the text box to the Panel user control, if I set the multiline property then all is well, but when I compile my panel/text hybrid control and place it on a form, then all the properties from the panel user control are serialised, but the properties of the text box are not. I view this as pretty obvious behaviour which seems to make sense, but how do I work around it?
Nursey
|
|
|
|
|
at design time on the panel control, set Modifiers property of the textbox to Public or Friend. no need to use anaa property 2 xpose the same.
then u'll b able to manipulate the text box anywhere.
|
|
|
|
|
Kamush,
Thanks, but that's not the answer. First, I have already exposed the text box as you say by making it public. But two things, firstly when the programmer changes the properties at DESIGN TIME, the windows designer doesn't seem to generate code to effect those property changes at run time. I don't know why. Second, I asked, can my PANEL control expose all the events of the TextBox. My feeling is it can't, without inheriting TextBox, which I can't do because I want a panel that CONTAINS a text box.
As I said, this kind of makes sense but its frustrating. or....I still don't understand something, and your answer is right, and my understanding of it is wrong 8-)
Thanks.
Nursey
|
|
|
|
|
Hi Every one
i am making a project, in which i need to draw the charts by means of simple drawing methods as used in VB.Net. So that i can make any type of chart i want
to draw. I want to draw the charts like in MS Acess.
Thanks
Eman Ali.
|
|
|
|
|
Great! And your question is?
RageInTheMachine9532
|
|
|
|
|
|
First, I have to question why you would want to do this? There are many controls already out there that handle chart drawing of any imaginable type. I just don't see the point in reinventing the wheel...?
But if you must, you could use a PicBox or draw directly on the Form itself. I would suggest writing this as a control using a PicBox so it can be reused in other projects. First, you have to work out a method of keeping track of data. This is going to depend on the type of data your working with. Then, you calculate the scaling for your data, then calculate the size of your chart and its scaling in the PicBox. Your also going to have to calculate positions for labels and font scaling.
When you have all that, you have to write your code to paint the chart in the Paint event of your control. Get a Graphics object for the PicBox by using the CreateGraphics method of the PicBox. Then you can use the Graphics objects methods to draw what your chart is going to look like.
Just as an example of drawing using the Graphics object, this is a little snippet of code from a goofy little control project I worked on a while back:
Private Sub threadDrawingLines()
Dim x As Integer
Dim objPen As New Pen(Color.Blue)
Dim grPicBox As Graphics = PictureBox1.CreateGraphics
Try
While (pNumberOfLines > 0)
For x = 1 To pNumberOfLines
grPicBox.DrawLine(objPen, Lines(x, 1), Lines(x, 2))
Next
UpdatePositions()
Thread.Sleep(pSleepTime)
End While
Catch ex As ThreadAbortException
grPicBox = Nothing
objPen = Nothing
End Try
End Sub
RageInTheMachine9532
|
|
|
|
|
tahkns for the help. Its mean that what i was doing is write i am making my own charts . The reason why , which you have asked , The answer is that i have devoloped the clases for printing so what ever i draw on the panel will go as an output to the printer. And the project on which i am working is a document formatter which is connected to some data sourse and the charting facility like Acces is a main module for the project. so Thats why i am doing all my own.
|
|
|
|
|
i have a picbox which user will draw different kind of drawing on the picbox,
i trying to find a way which when user draw the first drawing, i save the content of the picbox to a place, after user define the second drawing, i will copy the saved content back to the picbox to attach to the second drawing, so all the drawing will retained... someone suggested me use double buffering on the picbox to save the picbox into a bitmap file, but i am really a beginner in VB.Net, can someone provide me about the coding of double buffering on the picbox?? thanks very much for any help!!!
|
|
|
|
|
sounds like RageInTheMachine9532's q . do this so u retain both images - no need 2 save 1st image:
private sub picbox_paint(e....) .... handles paint
if drawmode = 1 then 'first time user draws
e.graphic.drawrWW() 'this is the first drawing
picbox.invalide() 'refresh picbox
end if
if drawmode = 2 then 'this means user chose draws anaa shape
e.graphic.drawWW() 'this is the first drawing
e.graphic.drawXX() 'this is second drawing
picbox.invalide() 'refresh picbox
end if
end sub
|
|
|
|
|
Hi i am using RS232 class which is new concept in .NET.i am using the latest RS232 class.
but i am not able to retrieve any data,i have used "Inputstream" property of Comm.even though it shows some error,if any one know the exact method,please do let me know
|
|
|
|
|
i have form1 and form2, form1 has a picturebox which i already drew something on it(e.g. rectangle)
i active form2 to chose another shape to add below the rect, after form2 closed, the new shape should be added below the rect and the rect should be remained in its original position on the picbox(something like drawing flowchart).i used picbox_Paint event handler to draw the rect, but when i added new shape using the same Paint handler the rect is gone??!is there anyway to fix this problem?? what i try to find is the way to keep the drawing on the picbox remained till the application is closed... below is my current coding summary
private sub picbox_paint(e....) .... handles paint
if drawmode = 1 then
e.graphic.drawrect() 'this is the first drawing
picbox.invalide() 'refresh picbox
end if
if drawmode = 2 then 'this means user chose another shape from form2
e.graphic.drawXX() 'this is second drawing
picbox.invalide() 'refresh picbox
end if
end sub
|
|
|
|
|
You have to rewrite your paint handler to paint BOTH rectangles. WHat your doing in your handler is telling the PicBox to invalidate it's entire client area. THen your handling the paint event yourself, but never redrawing the first rectangle. You have to modify your code to keep track of EVERYTHING that you want repainted in the picbox, then redraw it all yourself since your handling the paint event yourself.
RageInTheMachine9532
|
|
|
|
|
Guess RageInTheMachine9532 is saying this so u retain both images:
private sub picbox_paint(e....) .... handles paint
if drawmode = 1 then
e.graphic.drawrect() 'this is the first drawing
picbox.invalide() 'refresh picbox
end if
if drawmode = 2 then 'this means user chose another shape from form2
e.graphic.drawrect() 'this is the first drawing
e.graphic.drawXX() 'this is second drawing
picbox.invalide() 'refresh picbox
end if
end sub
|
|
|
|
|
thanks for RageInTheMachine9532 and kamush help!!
but wat i actually drawing is a flowchart, which mean each time user define a new drawmode or shape, the coding is very long and complicated and the label of the drawing will be different...if i change the code to wat u suggested me, my coding will be tremedous long and complicated!!
i dunno whether u understand me or not(my english is pretty poor)...
anyway thanks for ur help...i post a new question about this problem, if u have new idea plz reply there ok? thanks very much!!
|
|
|
|