|
i am developing an app in which i have used graphics object to create and fill
a rectangle with some color.
now i want to know when the user clicks inside the rectangle
but i am getting some problems
currently i am doing this with if-elseif conditions
wouldn't a much better way to do this is by associating
the click event to the rectangle
i can't figure out how to associate events with the rectangle
is it possible?
if yes then
please help
else
tell if there any other way of doing it
other than using a label or a picture box
end if
thanx
TheMrProgrammer
|
|
|
|
|
Hi,
The only UI objects that support events are Controls. Most of them are rectangular, so you are in luck. You could use say a Panel and set its background color.
OTOH a Rectangle has a Contains() method which takes a Point, and a MouseEventArg gives you a Point, so you don't have to switch to Controls (which wouldn't make things easy when non-rectangular anyway).
Luc Pattyn [Forum Guidelines] [My Articles]
The quality and detail of your question reflects on the effectiveness of the help you are likely to get.
Show formatted code inside PRE tags, and give clear symptoms when describing a problem.
|
|
|
|
|
thanks
but whats OTOH
TheMrProgrammer
|
|
|
|
|
Google for unknown acronyms.
OTOH means 'On The Other Hand'
Henry Minute
Do not read medical books! You could die of a misprint. - Mark Twain
Girl: (staring) "Why do you need an icy cucumber?"
“I want to report a fraud. The government is lying to us all.”
|
|
|
|
|
hello every one
i m having '11' tabpages in tabcontrol now in each page there are 11 combobox
i named them starting from '0' like cmb0 which is in 1st tabpage,cmb1 which is in second tabpage and like wise...
now all 11 comboboxes have same items in it and i want to insert all of them using loop
for that i had code is like
dim i as integer
cmbstr as combobox
For i = 0 To 11
cmbstr = cmbstr & i
cmbstr.Items.add("a")
cmbstr.Items.add("b")
cmbstr.Items.add("c")
cmbstr.Items.add("d")
Next
i = i + 1
but this shows some error
please help..
please suggest if some another alternative is possible..
|
|
|
|
|
nazimghori wrote: but this shows some error
And that error would be ....... ??? Do you really think that there's only a single error possible when dealing with a combobox??
|
|
|
|
|
Let me do a mind meld with the computer (just seen the new Star Trek move) uhm, uhm, oh bugger that's the monitor you idiot now you've got indentations on the flat screen!
Never underestimate the power of human stupidity
RAH
|
|
|
|
|
hi
error is like
operator '&' is not not defined for type 'system.windows.form.comboox' and integer
seems to be syntax error but please suggest how to solve it...
thank you in advance...
|
|
|
|
|
Of course not. You're trying to build the name of a ComboBox in a string and then treating that string as if it was the combobox. That's not going to work.
Luc has the best two solutions for you.
modified on Sunday, May 10, 2009 9:46 PM
|
|
|
|
|
There are several approaches possible:
1.
create a ComboBox array or collection (a generic list), copy a reference to each of the comboboxes in the list once (say in your form load handler), then do a foreach over that array every time you need to.
2.
assuming there is only the one combobox on every tab page, execute the following pseudocode:
foreach tabpage in tabcontrol
foreach control in tabpage
if control is combobox (skipping the other controls, e.g. buttons)
do what needs to be done
Luc Pattyn [Forum Guidelines] [My Articles]
The quality and detail of your question reflects on the effectiveness of the help you are likely to get.
Show formatted code inside PRE tags, and give clear symptoms when describing a problem.
modified on Sunday, May 10, 2009 8:03 AM
|
|
|
|
|
hello
i knew this approach but there are more than one combobox on each tabpage...
so please suggest some other approach...
|
|
|
|
|
I gave you two solutions, the first works no matter what.
the second can be modified to cope with multiple comboboxes per tabpage: give the ones you want a special characteristic (e.g. through their Name, their Location or their Tag) and test inside the "foreach control" loop.
Luc Pattyn [Forum Guidelines] [My Articles]
The quality and detail of your question reflects on the effectiveness of the help you are likely to get.
Show formatted code inside PRE tags, and give clear symptoms when describing a problem.
|
|
|
|
|
hello
i tried the second approach i gave the tag values of each combobox in tabpage to '0' at design time..
Sub fill(ByVal tbcon As TabControl)
Dim cnt As Control
For Each cnt In tbcon.Controls
If TypeOf cnt Is ComboBox Then
Select Case Tag
Case 0
cnt.Items.Add("NP")
cnt.Items.Add("ND")
cnt.Items.Add("FP")
cnt.Items.Add("FD")
End Select
End If
Next
End Sub
but this shows the syntax error like
'item is no the member of 'system.windows.forms.controls'
please help....
|
|
|
|
|
Of course your code does not compile: cnt is declared a Control, and Control does not have an Items property. You need to cast it to a ComboBox, something like Dim combo as ComboBox=DirectCast(cnt, ComboBox)
Luc Pattyn [Forum Guidelines] [My Articles]
The quality and detail of your question reflects on the effectiveness of the help you are likely to get.
Show formatted code inside PRE tags, and give clear symptoms when describing a problem.
|
|
|
|
|
..it should read somthiing like:
Sub fill(ByVal tbcon As TabControl)
Dim cnt As Control
For Each cnt In tbcon.Controls
If TypeOf cnt Is ComboBox Then
Select Case CType(cnt, ComboBox).Tag
Case 0
cnt.Items.Add("NP")
cnt.Items.Add("ND")
cnt.Items.Add("FP")
cnt.Items.Add("FD")
End Select
End If
Next
End Sub
Otherways the compiler doesn't know 'Tag'
Regards: Didi
|
|
|
|
|
hello
i tried another alternative like
dim cmbcntrl as combobox
Dim combos() As String = New String() {"NP", "ND", "FP", "FD"}
dim i as string
For i = 0 To 11
cmbcntrl = cmbcntrl.Items.AddRange(combos)
next
there are 11 comboxes and 11 tabpage each tabpage having 1 combobox now i name these comboboxes like combobox0,combobox1,combobox3.....and also there are other comboboxes in tabpages but they are with different name..
and tried above loop
but still theres an error like:- 'expression doesnot produce a value..'
so please suggest what shall i do..
thank you....
|
|
|
|
|
hello
i tried other approach like
Dim combos() As String = New String() {"NP", "ND", "FP", "FD"}
Dim i As Integer
dim cmbcntrl as combobox
For i = 0 To 11
cmbcntrl = cmbcntrl.Items.AddRange(combos)
i am having 11 comboboxes and 11 tabpages each having one combobox now i name these comboboxes like :combobox0,combobox1,combobox3....upto '11' and also there are other comboboxes in some tabpages but they are with different name....
now i tried above loop
but it still states the syntax error like 'expression doesnot produces a value...'
so please suggest what shall i do to solve it..
thank you....
|
|
|
|
|
Dim arr() As String = {"NP","ND","FP","FD",...}
For Each tabPage In TabControl1
For Each control In TabPage
If control Is ComboBox Then
control.Items.AddRange(arr)
End If
Next
Next
Surely this works
I don't speak Idiot - please talk slowly and clearly
I don't know what all the fuss is about with America getting it's first black president. Zimbabwe's had one for years and he's sh*t. - Percy Drake , Shrewsbury
Driven to the arms of Heineken by the wife
|
|
|
|
|
hello
the code suggested had an syntax error like
'tabpage is a type and cannot be used as an expression'
so please suggest what shall i do to solve it....
|
|
|
|
|
I need to know how to do some simple things with arrays please help with any!
1.Find largest of smallest value
2.Count how many times a given value is in the array
3.Count the number of even or odd integers in the array
4.Add up the sum and compute the mean
5.Create another array of the same size containing the same values in reverse order
Thanks!
|
|
|
|
|
VB help ? Here in the VB forums ? Really ?
Sounds like homework to me. The obvious thing to do is use foreach to step over an array and calculate these things.
Christian Graus
Driven to the arms of OSX by Vista.
"I am new to programming world. I have been learning c# for about past four weeks. I am quite acquainted with the fundamentals of c#. Now I have to work on a project which converts given flat files to XML using the XML serialization method" - SK64 ( but the forums have stuff like this posted every day )
|
|
|
|
|
This is homework from your class. If we do it for you then you won't learn anything. You MUST try it yourself first. If you get stuck post the code and what you were trying to do and then someone will help you through it. Until then please make an effort.
Man who stand on hill with mouth open wait long time for roast duck to drop in
|
|
|
|
|
He's stuck at starting. I'm convinced these people don't know how to open Visual Studio or, if they get that far, start a new project.
|
|
|
|
|
Hi if anyone could help I would appreciate it. I have a database with a
Movies Table, Casting Table, and Actor Table.
Movie Table has MovieID
Casting Table has MovieID , and ActorID
Actor Table has ActorID
This code deletes a row from the movies table(using a datagrid in vb.net), I need all the rows in the Casting table with the same MovieID to also be deleted.
Any help would be appreciated!!
Dim result As String
Dim i As Integer
i = MovieDataGridView.CurrentRow.Index
result = MsgBox("Are you sure you want to delete this movie?", MsgBoxStyle.OkCancel)
If result = vbOK Then
If MovieDataGridView.Rows.Count = 1 Then
MsgBox("You must leave one movie in database!!")
Else
Me.MovieDataGridView.Rows.Remove(Me.MovieDataGridV iew.SelectedRows(0))
End If
Else
End If
Me.Validate()
Me.MovieBindingSource.EndEdit()
Me.TableAdapterManager.UpdateAll(Me.MovieProjectDa taSet)
|
|
|
|
|
I will leave answering your question to those with more knowledge than I.
However, If after waiting a few hours (remember this is the weekend) you have not received an answer, I would suggest this would be better asked in the General Database forum.
Also, it seems strange to insist that there be at least one movie in the table. Care to share the reason for this?
Henry Minute
Do not read medical books! You could die of a misprint. - Mark Twain
Girl: (staring) "Why do you need an icy cucumber?"
“I want to report a fraud. The government is lying to us all.”
|
|
|
|