|
Thank you for the quick reply!
I can do that within a class or a structure, but not within a matrix of some kind of object/class. That's the problem, an event, whatever it is, cannot be associated to a matrix (1-dimension in my case): it's what I read from MSDN and compiler errors until now. Anyway, I continue searching in the direction you gave me.
One more hint:
think about coding a windows application to play puzzle, this is a form with two panels and the programs read from a file the numbers of puzzle's items. Then it loads items into Panel1 and you (user) must drag&drop items into Panel2.
This all works fine if I set as costant the number of items (like =10) and in this case I don't need to create an array at runtime but I create 10 buttons on my form at design time. How can I do if I don't know the items number before? Hope you got it.
Thank you again.
---
die
|
|
|
|
|
diebugger wrote: I can do that within a class or a structure, but not within a matrix of some kind of object/class.
The button events still fire, no matter what collection they are in. You can still wire up the events to a handler in the form code.
diebugger wrote: but not within a matrix of some kind of object/class.
Matrix has no meaning here. Are you saying that you want to wire up the events to a method in a custom class??
diebugger wrote: think about coding a windows application to play puzzle, this is a form with two panels and the programs read from a file the numbers of puzzle's items. Then it loads items into Panel1 and you (user) must drag&drop items into Panel2.
I wouldn't be using buttons, or any other controls, to represent the pieces, that's for sure.
|
|
|
|
|
you should add a handler to each of the Controls (not to the array).
this takes a single line of code inside the loop that creates the Controls!
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
|
|
|
|
|
That was. Thank you, I'm just at the beginning of this event driven programming
---
die
|
|
|
|
|
As far as i can see, what you want to do at this stage is to create a Matrix(Array) of button, and when you get the number from outside you need to load those buttons.
So for that you can write for loop and declare global variable which will store the X number you get from out side and put the code of loading button.
This is how you can do it.
1. Create one button and put it's Index to 0
2. Start your for loop from 1
For i=1 to x<br />
load button <br />
button index = i 'this will get you the name of button e.g. button1(1)<br />
Next i
3. And now you can put you functions init.
Hope this helps you. If you have any questions feel free to ask.
Parth Patel
|
|
|
|
|
Hey all!
I'm having a situation here whereby I would like to join two bitmaps and make it as one.
How can I do that?
I've already got two bitmaps, both having their own set of drawings; Lets call them Bitmap1 and Bitmap2......now I would want to union them together so that the final result would be a bitmap that will contain everything from Bitmap1 and then just after Bitmap1, Bitmap2 will be appended to it. So im not trying to overlap them with one another, i just want bitmap2 to appear right after bitmap1.
Thanks in advance!
Regards,
jensen
|
|
|
|
|
Try creating a new Graphic and using a For loop over all the pixels of an image using the GetPixel() method. So if image 1 is 300x300 and image 2 is 300x300 then create a new graphic with size 600x300 and place the pixels in the new graphic by using SetPixel()
Good Luck!
--Zaegra--
|
|
|
|
|
Zaegra is partially correct.
You create a new Bitmap object the size of the two bitmaps you want combined. So, if you want Bitmap2 to show up under Bitmap1, create a new Bitmap object the height of Bitmap1 + the Height of Bitmap2 and the width of the widest of your two bitmaps. Then you create a Graphics object from this new Bitmap object and use it to "DrawImage" the other two bitmaps onto your new Bitmap in the appropriate positions.
|
|
|
|
|
Alright thx for the response!
I'll get on working with the concept!
Will buzz again if i encounter some issues, hope not!
Thanks once again!
Regards,
jensen
|
|
|
|
|
Hi Friends..
I am ahving a stored procedure rturn in which i have the First column as Guid.Now i am showing the stored procedure return in a datagrid and now i need to take Guid alone and display it in a message box..I am using the following code .But it errs..
gmdataset = lobjservice.Job_Status(lstrfromdate)
Me.DataGrid1.DataSource = gmdataset.Tables(0)
-------------------------------------------------
Private Sub btnRerun_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnRerun.Click
mstrjobid = Me.DataGrid1.Item(DataGrid1.CurrentRowIndex, 0)
MsgBox(mstrjobid)
End Sub
-------------------------------------------------------------
I am getting the error "Cast from type 'Guid' to 'string' is not valid
Someone help in this regard..
Regards,
Balaguru
|
|
|
|
|
Call the ToString() method on your object instance to return its string representation.
Paul
|
|
|
|
|
I tried it..But still i am getting the same error..
Regards,
Balaguru
|
|
|
|
|
You must still be doing something wrong. Post your code.
Paul
|
|
|
|
|
Balagurunathan S wrote: Private Sub btnRerun_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnRerun.Click
mstrjobid = Me.DataGrid1.Item(DataGrid1.CurrentRowIndex, 0)
MsgBox(mstrjobid)
End Sub
OK. So where does mstrjobid get defined?? What does that code look like??
I get the feeling that it's defined as a String and not Guid like it should be.
If that's the case, then yes, you'll get the error that you're seeing because you're trying to assign a Guid object to a variable declared as String.
But, to get your code "working",
mstrjobid = DataGrid1.Item(DataGrid1.CurrentRowIndex, 0).ToString()
|
|
|
|
|
Hi Dave..
Thanks very much for the help.I got it right..Thanks for all who replied for this post..
Regards,
Balaguru
|
|
|
|
|
i have boolean.. and if FALSE then i want the context menu to have
add
edit
delete
if TRUE then just
edit
delete
i have some other scenarios that will be similar to this...
anyone know a good way to approach this?
Thanks for your time
red
|
|
|
|
|
Create a context menu with all three menu items. Then at run time you may set visible property of Add menu item to false by checking the value of Boolean variable.
Such as-
----------------------
If bln = True Then
Me.AddToolStripMenuItem.Visible = False
End If
--------------------
I hope this helps .
-Dave.
Dave Traister,
ComponentOne LLC.
www.componentone.com
|
|
|
|
|
Me.AddToolStripMenuItem.Visible = Not myBoolean
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
|
|
|
|
|
cool thanks
|
|
|
|
|
thanks dave, thatll do it. simpler than what i thought i had to do..
nice one, cheers
red
|
|
|
|
|
hi i'm stell new to vb.net & i have this error message i just want to know what dose it mean??
" unhandled exception of type 'System.FormatException' occurred in system.data.dll
Additional information: Input string was not in a correct format
i'll copy the code to you to see with me(
<b>Imports System.Data.SqlClient
Public Class branch_code
Inherits System.Windows.Forms.Form
Private Sub b_save_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles b_save.Click
' Declear paramter
Dim par1 As New SqlParameter("@branchid", SqlDbType.Int, 4)
par1.Direction = ParameterDirection.Input
cm_pink.Parameters.Add(par1)
''Set values for all poarameters
par1.Value = tb_branch_id.Text
''set command text
cm_pink.CommandText = "insert into Branch ([Branch Name])" & _
"values (@branchname)"
'---------------------------
If tb_branch_name.Text = "" Then
Error_name.SetError(tb_branch_name, "Please Insert Name Here ")
Else
End If
check_connetion()
cm_pink.ExecuteScalar()
' Dim count As Integer
'count =
' StatusBar1.Text = CStr(count) & " Row Inserted "
cn_pink.Close()
cm_pink.Dispose()
cm_pink.Parameters.Clear()
End Sub
Private Sub b_clear_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles b_clear.Click
clear(Me)
End Sub
Private Sub b_Cancel_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles b_Cancel.Click
Me.Close()
End Sub
Private Sub branch_code_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
End Sub
End Class)
thanks for any helpe
Hend alraie
-- modified at 7:06 Tuesday 25th September, 2007
|
|
|
|
|
Which line gives the error ?
I do think you need a space between ) and the v in values.
I also see that the parameter you're adding is branchid, not branchname.
Overall, I'd say if you're new to VB.NET, you should not be working on this code, unless you have a background in C#.
Christian Graus - Microsoft MVP - C++
"I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )
|
|
|
|
|
the error in this line
cm_pink.ExecuteScalar()
|
|
|
|
|
nowdy wrote: cm_pink.CommandText = "insert into Branch ([Branch Name])" & _
"values (@branchname)"
This is the problem with concantenating string together. Like Christian pointed out, you're missing a space between the ")" and "values" in your resulting string, which looks something like this:
insert into Branch ([BranchN Name])values (@branchname)
which, in SQL, is a problem. There must be a space just before "values".
|
|
|
|
|
nowdy wrote: par1.Value = tb_branch_id.Text
Your other issue is this line. You might want to try validating the entered text AND convert it to an Integer before you try and assign it to the parameter value.
Dim branchId As Integer
If Integer.TryParse(tb_branch_id.Text, branchId) Then
' Create your parameter object and assign the value of
' branchId to it's Value property.
' Then you can do your query
End If
If the TryParse statement returns False, the text entered could not be converted to an Integer, invalidating your SQL lookup.
|
|
|
|