|
Hello,
Their is a Traditional way, for all variable(different datatype).
i,e. Consider,
Dim str As String = "Iam a string"
Dim integ As Integer = 0
Dim da As Date = "#6/22/2007#"
Dim ss As String
ss = "'" & str & "' " & integ & " '" & da & "'"
Answer = 'Iam a string' 0 '6/22/2007'
I thing u got the answer. If hve any problem msg me friend...........
|
|
|
|
|
Hi, i have a list box with some items in it. I would like to know the sample code that I could determine whether any item in the listbox is select or not?
Thank in advance
|
|
|
|
|
You can try .SelectedIndex method of list box
Regards,
Nilesh
|
|
|
|
|
Thank you for your reply. I will try to test it.
|
|
|
|
|
Hi,
depending on ListBox.SelectionMode you can use some properties:
either SelectedItem and SelectedIndex
or SelectedItems and SelectedIndices
Luc Pattyn [Forum Guidelines] [My Articles]
this weeks tips:
- make Visual display line numbers: Tools/Options/TextEditor/...
- show exceptions with ToString() to see all information
- before you ask a question here, search CodeProject, then Google
|
|
|
|
|
Thank you for your comment. But I do not want to know the selection mode. What i want is whether any item in my listbox is select or not. My list box selection mode is set to select only one item only.
Thank you for your support
|
|
|
|
|
as I said it depends on the selectionmode which two of the four properties I mentioned
you should use.
Luc Pattyn [Forum Guidelines] [My Articles]
this weeks tips:
- make Visual display line numbers: Tools/Options/TextEditor/...
- show exceptions with ToString() to see all information
- before you ask a question here, search CodeProject, then Google
|
|
|
|
|
if you want to know wheter or not there is a selected item:
if listbox.selecteditems.count = 0 then
'nothing is selected
else
'something is selected
end if
if you want to know wich item is selected
when there can be more than 1:
listbox.selecteditems 'contains all the selected items
when only 1 is possible:
listbox.selecteditem
if you want to know the index of the selected item
when there can be more than1:
listbox.SelectedIndices 'contains all the indeces for all the selected items
when only 1 is possible:
listbox.selectedindex
|
|
|
|
|
Thank you for your detail explaination.
|
|
|
|
|
hello frnd,
check listbox1.selectedItem.count > 0
regards,
koolprasad2003
Be a good listener...Because Opprtunity knoughts softly...N-Joy
|
|
|
|
|
Thank you for your support.
|
|
|
|
|
in a listbox if no item is selected the selectedindex = -1 so:
if me.listbox1.selectedindex = -1 then<br />
'nothing is selected<br />
end if
|
|
|
|
|
Thank you, this is what I need.
|
|
|
|
|
i want to create annotation (rectangle box with transparent) with selection of user mouse, like that i want to select all parts of the image and save the coordinates using picture box tool
please help
regards
sathish
-- modified at 7:06 Wednesday 8th August, 2007
|
|
|
|
|
hello there
i just begun to create my control,
when i create a class project, add the references. when i write
private sub new() (and press enter)
end sub
the code looks like something like that
when i take customcontrol and do the same the code is
private sub new()
' This call is required by the Windows Form Designer.
InitializeComponent()
' Add any initialization after the InitializeComponent() call.
end sub
what m i missing in the class file
then
i give the mybase.backcolor
that will show the control's color and its fine
but now i need to draw some drawing on that "mybase" how can i do that to give my control a shape and also i need to draw an another drawing on that control that will move on to that control vertically or horizontaly.
does someone knows the documentation about that or any kind of help
thanx in advance
|
|
|
|
|
you aren't missing anything in the class file
a constructor in a class file doesn't contain the initializecomponent because it has no controls to initialize
the initializecomponent in a customcontrol or windows form is located in the designer and creates,sets property's of the controls you put on to that customcontrol or windows form.
since a class doesn't contain controls it is not needed
to give you'r control a shape look into the region property
Dim arrRegion As ArrayList = 'fill array with points
If Not arrRegion.Count = 0 Then
Dim pntRegion(arrRegion.Count) As Point
pntRegion = arrRegion.ToArray(GetType(Point))
Dim c As New System.Drawing.Drawing2D.GraphicsPath
c.ClearMarkers()
c.AddCurve(pntRegion)
If Not c Is Nothing Then
Me.Region = New Region(c)
End If
End If
with this you can give you're control any shape you want
for the drawing that has to move I suggest you create a second customcontrol (with its region adjusted) place it on you'r first and adjust the position when needed
|
|
|
|
|
can u tell me something about
Protected Overrides Sub OnPaint(ByVal e As PaintEventArgs)
end sub
or
Protected Overloads Overrides Sub OnPaint(ByVal e As PaintEventArgs) MyBase.OnPaint(e)
end sub
what should i use in my program
both gives an error when i use them in class file
both gives no error when i use them in customcontrol file
where should i write the code, in my function or the one of them as on up
thnx
|
|
|
|
|
well if you want to set the region of the control you can do that in the load of the control
if you want to draw something on the control (using the graphics) you should be able to use
Protected Overloads Overrides Sub OnPaint(ByVal e As PaintEventArgs)
'you're code comes here
MyBase.OnPaint(e)
End Sub
or for a custom control
Private Sub ctrlLineHorizontal_Paint(ByVal sender As Object, ByVal e As System.Windows.Forms.PaintEventArgs) Handles Me.Paint
End Sub
keep in mind that the code you place inside the paint methode/event will me run everytime you're control repaints and this happens when you
move the control (at run time) (or parent control/form)
when another window is placed on top of it and then you return to the control
when you resise the control (or parent control/form)
so it would be wise to keep the code inside the paint methode/event to an absolute minimum
|
|
|
|
|
how can i set the region of the control at load of the control
did u mean the load event of the control (the control does not have the load event)
second
Protected Overloads Overrides Sub OnPaint(ByVal e As PaintEventArgs)
'you're code comes here
MyBase.OnPaint(e)
End Sub
r u confirmed about the position of the ('you're code comes here) in the code
because in all examples i saw the position of ('you're code comes here) is
Protected Overloads Overrides Sub OnPaint(ByVal e As PaintEventArgs)
MyBase.OnPaint(e)
'you're code comes here
End Sub
can u plz give me an example of that what i m trying to do
|
|
|
|
|
1: normally every usercontrol has a load event (doubleclick on the control should automaticly place you in the code of the event)(otherwise you can select the event in the 2 comboboxes just above the code(in code view) first comobox: (usercontrol1 events) second combobox: load)
2: I'm not sure but I don't think the placement of the mybase.onpaint(e) matters
example (kryptic)
public sub load event
me.region = new region... 'see previous posted code
end sub
Protected Overloads Overrides Sub OnPaint(ByVal e As PaintEventArgs)
MyBase.OnPaint(e)
e.graphics.drawline(...)
e.graphics.drawstring(...)
'...
End Sub
if you give me a more detaild description of what exactly it is that you want I could give you more detailed code
what needs to be drawn?
what shape is you're control?
when does the movement happen (all the time or when you tell it too)?
...
|
|
|
|
|
what i need to draw is a ruler control
which contain
1. a background.
2. some number on that control at specified distance like inches.
3. some vertical lines just like the normal scale has.
4. two slider's one is upper and the second one for lower usually as in the any application which is used to increase or decrease the page margin.
5. these slider's should be able to move horizontally or vertically on the ruler
i have tried it to write in class, customecontrol, usercontrol also
that some thing i worried about.
any suggestion is appreciated
thnx
help everyone
|
|
|
|
|
1. I'm asuming this is already done (me.backcolor=...)
2. (simple example)
Dim i As Integer = 0
For i = 0 To 10
e.Graphics.DrawString(i, New Font("arial", 8), Brushes.Black, i * 10, 5)
Next
3. (simple example)
Dim i As Integer = 0
For i = 0 To 10
e.Graphics.DrawLine(Pens.Black, i * 10 + 5, 0, i * 10 + 5, 10)
Next
4. create 2 new controls and give them the shape of an arrow with the region property
5. I'm boxing something together for this and get back to you
1 can be done in the load of you're control or in a property
2 and 3 are best done in the paint event
|
|
|
|
|
I've created a very simple example but it is to much code to post here
Can you provide me with an email so I can send it to you
You can mail me directly from this site (choose email instead of reply)
|
|
|
|
|
i think u already had my mail id
i sent a mail to you check it out.
again thnx
help everyone
|
|
|
|
|
thnx for the reply
but plz can u provide the same in English
the example u send that's in some other language and i m unable to understand it, so it will be greateful if u send me it in some simple english. hope u will help me. again thnx for reply
help everyone
|
|
|
|