|
You have several statements/questions here, some of which are confusing.
Indra_PR wrote: After scripting on both of them, I built the project and I got 1 dll file: WindowsControlLibrary1.dll.
What scripting are you doing or did you mean compile?
Indra_PR wrote: How can I do that, what should I do to get the controls inside the dll file. I want to use it as part of the new project. So that if i call function like: UserControl1.Show(), the UserControl will be appeared under the main form of the new project, and have all function as child form.
Normally, you would add a reference and then use the controls you created. If you intend on re-using the same form stle with the controls you created, you might want to make another .dll, create a template form with the custom controls you created and some public properties. You could then create the form (dynamically if really needed) at runtime (and the datagridview would be populated correctly depending on the value of the public properties) regardless where it's called from.
Code for creating assembly dynamically:
Try
ao = [Assembly].LoadFrom(sFullPathIncludingFileName)
o = ao.CreateInstance(sAssembly & "." & sClass, True)
Catch ex As Exception
Throw ex
End Try
Indra_PR wrote: Can someone help me? If I could do that, next I want to add the path of the dll inside SQL Server database. When I run the main form, it will read the path, and dinamically run them as the MDI child on runtime.
I don't think you would want to do this from a SQL database......doesn't make sense to do so. Generally, when calling a .dll natively from SQL, you want the .dll to be performing a complex operation that would perform better outside of SQL or gain 'easier' access to resources (folders, directories, ftp, email, etc); typically, you wouldn't want to display a GUI app.
Tackle one part at a time and try to remove some of the complexity you got going on.
Any suggestions, ideas, or 'constructive criticism' are always welcome.
"There's no such thing as a stupid question, only stupid people." - Mr. Garrison
|
|
|
|
|
I made a function like this:
Public Shared Function LoadAssembly(ByVal AssemblyPath As String, ByVal ClassName As String) As Object
Dim objAssembly As Reflection.Assembly
objAssembly = Reflection.Assembly.LoadFrom(AssemblyPath)
Try
LoadAssembly = objAssembly.CreateInstance(ClassName, True)
Catch ex As Exception
MsgBox(ex.Message)
Return Nothing
End Try
If LoadAssembly Is Nothing Then
MsgBox("Assembly : " & AssemblyPath & vbNewLine & "Class : " & ClassName)
Return Nothing
End If
End Function
And I call the function in the form load of the new project:
Dim frm As Form
Try
frm = LoadAssembly("C:\WindowsControlLibrary1.dll", "WindowsControlLibrary1.Form1")
Me.IsMdiContainer = True
frm.MdiParent = Me
frm.Dock = DockStyle.Fill
frm.Show()
Catch ex As Exception
MsgBox(ex.Message)
End Try
In order to make it works, I create 1 form inside the WindowsControlLibrary1.dll that I name it Form1. But when I want to add the UserControl1 inside the form, I don't know what to do next.
Dim usc As Form
Try
usc = DirectCast(LoadAssembly("C:\WindowsControlLibrary1.dll", "WindowsControlLibrary1.UserControl1"), Form)
Me.IsMdiContainer = True
usc.MdiParent = Me
usc.Dock = DockStyle.Fill
usc.Show()
Catch ex As Exception
MsgBox(ex.Message)
End Try
This script returned an error:
Unable to cast object of type 'WindowsControlLibrary1.UserControl1' to type 'System.Windows.Forms.Form'.
I need to add the UserControl1 on my project form. Is there any UserControl Container or something that I should add on my form?
|
|
|
|
|
The form IS the container. You're trying to treat a UserControl as a Form, which won't work at all.
You really need to rethink your design because what you're trying to do now just isn't going to work. The only option you have, with what you've got now, is to put that usercontrol on a form.
|
|
|
|
|
Wuaaaa thanks, I've modified my code.
Dim usc As UserControl
Try
Me.WindowState = FormWindowState.Maximized
usc = LoadAssembly("C:\WindowsControlLibrary1.dll", "WindowsControlLibrary1.UserControl1")
usc.Dock = DockStyle.Fill
Me.Controls.Add(usc)
Catch ex As Exception
MsgBox(ex.Message)
End Try
It works
Then I add uiBase.vb (UserControl) inside WindowsControlLibrary1, and made the UserControl1 inherits the uiBase. But when I was trying to call with "WindowsControlLibrary1.UserControl1" it failed to load. I've tried to call with parameter "WindowsControlLibrary1.uiBase.UserControl1" too, but it still returned me an error.
Ooooh, I need help here
Thanks
Best Regard,
Indra Permana Rusli
- No Signature Available -
|
|
|
|
|
Refer back to the replies from Dave and I.
Indra_PR wrote: Dim usc As UserControl
Try
Me.WindowState = FormWindowState.Maximized
usc = LoadAssembly("C:\WindowsControlLibrary1.dll", "WindowsControlLibrary1.UserControl1")
usc.Dock = DockStyle.Fill
Me.Controls.Add(usc)
Catch ex As Exception
MsgBox(ex.Message)
End Try
Where is this code snippet located. What is "me" in this instance? Is me referring to a form?
Any suggestions, ideas, or 'constructive criticism' are always welcome.
"There's no such thing as a stupid question, only stupid people." - Mr. Garrison
|
|
|
|
|
Yep, me refers to a form. It has no problem, the problem is in here:
usc = LoadAssembly("C:\WindowsControlLibrary1.dll", "WindowsControlLibrary1.UserControl1")
- No Signature Available -
|
|
|
|
|
It turns to be missing reference from my library. I have add the reference in the MDI parent project and it works.
- No Signature Available -
|
|
|
|
|
I have two combo box in Datagridview. one is Department and Manager.Initially i'm binding All the Department and All Manager in dropdown. when select the department then manager combo should bind with selected department manager. I have done till here.
but i'm facing a problem if i select one department in first row then it binds All rows with selected department's manager value. i want to bind it row wise. so every column in different row bind accroding to its department row wise.
any suggestion?
Amit Agarwal
|
|
|
|
|
So are you saying that you want to update the current row only? If so then you can use the grdMyGrid.CurrentRow property. When you change the value of your department dropdown, the CurrentCell property is set which in turn sets the CurrentRow property. You can then use something like
grdMyGrid.CurrentRow.Cells("ManagerCell").value = ManagerValue
If this is not what you meant then I apologise and can you post some of your code so I/we can get a better idea of the problem.
|
|
|
|
|
If the relation is one-to-one, I think you can do something like this:
Me.cboDepartment.DataBindings.Clear()
Me.cboDepartment.DataBindings.Add(New Binding("SelectedValue", Me.cboManager, "SelectedValue"))
I assumed that you made your combobox setting like this:
cboDepartment.ValueMember = "manager"
cboDepartment.DisplayMember = "department"
cboManager.ValueMember = "manager"
cboManager.DisplayMember = "manager"
So the program will read it like this:
cboDepartment.SelectedValue = cboManager.SelectedValue
cboManager.SelectedValue = cboDepartment.SelectedValue
Thanks, I hope this can answer your question.
Best Regard,
Indra Permana Rusli
- No Signature Available -
|
|
|
|
|
In my home everyone will use system all account are admin. Is there something I can do to keep my family from installing anything in the computer without my permission?
Main purpose is there are not seen the drive or drive space and license and options.
I saw 3rd party tool can i build such tools in vb.net
Plzz help me
Thanks.
|
|
|
|
|
I guess you could program this but I would try it with the user settings first.
Make one admin account (yours) and restrict all other account to user accounts.
Based on that you should be able to do most if not all off what you want.
|
|
|
|
|
Problem is my brother also use the Admin account that also password protect. He is installing many games so that I want prevent. plzz help me...
|
|
|
|
|
Well if you are an admin you can change his account into a normal user account.
Like I said you could write a program for this but it's not going to work as good as the windows security. And it will cost you alot off time.
|
|
|
|
|
Hi All,
I would like to know whether anyone had done Compact and Repair option using vb.net 2005 without using COM objects because it requires the registration of Dlls in the system.
Thanks
Latha
|
|
|
|
|
This article[^] is as close as your going to get using late binding. You really cannot do it without having Jet installed, which is a requirement for the .NET Framework anyway.
The code is in C#, but is easily converted to VB.NET using any online code conversion utility.
|
|
|
|
|
|
This list[^] is the best source of information you're going to get.
|
|
|
|
|
i want to display the image on crystal report from a database
and i m using VB.NET (Visual Studio 2005 and SQL server2005)
if have any suggestion for this Plz Send
Can any one help me on this
Regards
Amna
|
|
|
|
|
as you place other fields on report, simply place image related field in appropriate location.
Please note data type of this field is related to image.
have any more question?
|
|
|
|
|
This is from memory so can't really say for sure.
Depending on the version of crystal reports this is possible or not.
If your using the version that comes with visual studio (the free one) it's not (at least I didn't find a way)
If your using the newest version (that's not free) than I think you can put a image object onto the report which you can bind to a database field. Or tell it to use a 'url' to an image on the hard drive
|
|
|
|
|
Hi,
I need Help From You. Please Help Me. I was Tried But not Sucess.
How Can I Store Image in database & How Can Show them in Picturebox.
Please Help Me. I am Fresher in Dotnet.
I am Using VB.NET 2005 & For Database SQL 2000
Thanks & Regards
Form :-
Vikash Yadav
|
|
|
|
|
hi vikas,
you can create image type field in database and store byte array into this field.Simple follow these steps
1. first of all i assume PictureBox1 hold the picture data. So use following statement
Dim PictureBox1Data As Byte()<br />
If PictureBox1.Image Is Nothing Then<br />
PictureBox1Data = Nothing<br />
Else<br />
PictureBox1Data = imageToByteArray(PictureBox1.Image)'See below this function<br />
End If
2.Now write the SQL query as following
Dim QueryText As String<br />
Dim QueryValue As String<br />
Dim command As System.Data.SqlClient.SqlCommand = New System.Data.SqlClient.SqlCommand()<br />
QueryText = "INSERT INTO Settings(PrintCompany,IsUploadLogo,LogoGraphic )"<br />
QueryValue = "Values(@PrintCompany, @IsUploadLogo,@LogoGraphic)"<br />
command.CommandText = QueryText & QueryValue
3. Supply Value to parameter which is in above query, as following
command.Parameters.Add("@PrintCompany", SqlDbType.TinyInt, 10).Value = True<br />
command.Parameters.Add("@IsUploadLogo", SqlDbType.TinyInt, 10).Value =True<br />
If Not PictureBox1Data Is Nothing Then<br />
command.Parameters.Add("@LogoGraphic", SqlDbType.Image, PictureBox1Data.Length).Value = PictureBox1Data<br />
Else<br />
command.Parameters.Add("@LogoGraphic", SqlDbType.Image, 0).Value = System.DBNull.Value<br />
End If
4. Execute query as following
command.ExecuteNonQuery()
step 1 to 4 read data of picture box,convert them byte array and store in related table.Step 1 use following function to convert an image into byte array
Public Function imageToByteArray(ByVal ImageIn As System.Drawing.Image) As Byte()<br />
Dim ms As MemoryStream = New MemoryStream()<br />
Dim FormatImage1 As Imaging.ImageFormat = ImageIn.RawFormat<br />
ImageIn.Save(ms, FormatImage1)<br />
'ImageIn.Save(ms, Imaging.ImageFormat.Bmp)<br />
Return ms.ToArray()<br />
End Function
hope this helps
|
|
|
|
|
hi we R Using to Insert query to store imaga data
in Vb.NET
Means Something Like
insert into EmployeeTable(EmployeeID,Emp_Name,Address,Cell#,Image)
But there is an Error in concatination to Byte Type
The Data for image Is Byte Type How we can Manage The Query In case
and Im Database Field's DataType is Image,
It has to Store Binay Data
and I dont Want to Use
"command.Parameters.Add"
this way Plz Can U Help
|
|
|
|
|
Hi
I want to insert images in database (SQL Server 2005) Through VB.NET (Visula Studio 2005)
I m using Insert Query for this Purpose Means Somethink Like
Insert into EmployeeTable(EmployeeID,EmployeeName,EmployeeAddrress,EmloyeeContact#,EmployeeImage) Values (EmployeeID,Name,Address,Contact,Image)
But Here is a problem image data is Byte Type
and it is not concatenated in the Query Becoz Query Develops a string
this is the problem
And Can U please tell me the Proper way to Store and retrieve Image through programming
in VB.NET and i dont want to Use stored procedures for that purpose and
Also Don't want to Use "command.Parameters.Add" ethos Plz Provide any Other Solution
I m using
Datareader instead of Dataset
thanks and regards,
Amna
|
|
|
|