|
Just because you can do it, doesn't mean you should do it...
|
|
|
|
|
Hi,
how can i get the reference of existing(opened) form and manipulate its control properties like text,visbale etc on other form or within module? by doing new myForm does give reference of new instance rather existing one. Also, is there some different method to get instance in case of MDI application?
Would be greatful if I get some urgent response.
|
|
|
|
|
You've got a very bad design going.
You would have to pass these methods references to the forms that they would manipulate.
But, by doing so, you're completely trashing any and all concepts related to OOP and encapsulation of functionality.
No module should ever care about anything that is outside of its scope. Meaning, a method in a module shouldn't care that a form is using it. It shouldn't care about, nor use, the controls on any forms.
Forms should not be manipluating controls on other forms. Your forms should be exposing methods, and using other means, to tell themselves what to do to manipulate their own controls. This means your data model must support subscribers to events that you create, telling those subscribers that the data has changed. It's up to the subscribers to modify themselves in response to changes in the data.
|
|
|
|
|
I have a DatagridViewTextboxColumn. I allow word wrapping. When I am writting into the textbox, at run time, I would like to datagridview row height size to grow accordingly.
Here is my code:
Private Sub dgvDetail_CellEndEdit(ByVal sender As Object, ByVal e As System.Windows.Forms.DataGridViewCellEventArgs) Handles dgvDetail.CellEndEdit
RemoveHandler EditingControl.KeyUp, AddressOf editingControl_KeyUp
EditingControl = Nothing
End Sub
Private Sub dgvDetail_EditingControlShowing(ByVal sender As Object, ByVal e As System.Windows.Forms.DataGridViewEditingControlShowingEventArgs) Handles dgvDetail.EditingControlShowing
EditingControl = CType(e.Control, DataGridViewTextBoxEditingControl)
AddHandler EditingControl.KeyUp, AddressOf editingControl_KeyUp
End Sub
Private Sub editingControl_KeyUp(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyEventArgs)
EditingControl.EditingControlDataGridView.AutoResizeRows()
End Sub
Please help
Shay Noy
|
|
|
|
|
You're asking if you can set the size of the row WHILE you're editing the cell??
I don't know exactly how to pull this one off. The TextBox edit control won't resize itself while editing is taking place, so I don't see how you're going to get the "new" size of the control so you can set the size of the DGV row.
This is just pure speculation. You'd probably have to create your own edit control from scratch. You'd have to maintain the current size of the textbox while editing and have two-way communication between your control and the DGV so it can maintain the row size when the textbox size changes.
|
|
|
|
|
Hi,
I would like to have users read a pdf manual in my vb program. They can save the
unicode of text of a pdf file (text) into a database (wich should be done through searching a text in pdf programmatically). The pdf may be in anylanguage.
If somebody could help me on my way how to display a pdf file in my vb
program it would be a big step forward in my little project.
Thank you for your time...
|
|
|
|
|
You'll need a third party component, like Adobe Acrobat Reader or PDFnet[^], to read the PDF file and render it.
There is no built in support for PDF files in the .NET Framework.
|
|
|
|
|
Hi all,
I am developing OPC Client in VB.net. I have developed the code and reading OPC Items on Sampling as well as event based (OnDataChange). When I am working with local machine then my code works fine with both Sampling as well as OnDataChange, but when I am trying to read data from Remote OPC Server then Sampling works fine but I am not able fetch data on event based process. I am able to connect to the OPC Server but when i am adding subscription to it then i am getting error.
HRESULT : 0x80040202.
Public NetCredentials As New System.Net.NetworkCredential
Dim connectdt As Opc.ConnectData
Public WithEvents Subscription As ISubscription = Nothing
Public State As New Opc.Da.SubscriptionState
State = New Opc.Da.SubscriptionState
State.Active = True
State.UpdateRate = 500
Subscription = OpcServer.CreateSubscription(State)
results = Subscription.AddItems(Items)
AddHandler Subscription.DataChanged, New DataChangedEventHandler(AddressOf OnDataChange) ' Here is the error.
I appreciate if anybody suggests some solution.
Thanks in advance.
Prashant Khonde
Software Engineer
Navi Mumbai India
|
|
|
|
|
THis is possibly caused by a known issue, depending on which version of .NET you're using. Read this.[^]
|
|
|
|
|
I am using VS2005 with .net 2.0. This issue is something related to securities of Client and Server machines.
I am struggling with this issue from last 1 week and not able to resolbe the same.
Any suggestions ??????
Prashant Khonde
Software Engineer
Navi Mumbai India
|
|
|
|
|
Hi,
I need source code for importing data by character wise from excel to sql server using vb.net or C#. It is really very urgend. I hop u all help me.
Thanks in advance.
With Regards,
A.kamar
|
|
|
|
|
Noone is just going to hand over source code to do this. You have to write the code yourself, then we'll be happy to help you with any problems. But, just comming here asking for someone to do your work for you... that's just not going to happen.
This[^] is the best anyone is going to do to get you going.
|
|
|
|
|
kamarudeen wrote: I need source code
No.
"The clue train passed his station without stopping." - John Simmons / outlaw programmer
|
|
|
|
|
Hello every one
I am sorry to post this query again when there are already lot of old queries and article about this.. But some how I am not able to follow them
Can some one please help me out with how to add Combobox in DataViewGrid in VB.net 2005 Express.
I am not yet able to exactly figure out how we add a row and column to grid. Although, I am able to work around.
What all I understood till now is
- Add the column
- The add data to one column at a time for each row
- Repeat till all rows are not done
Plz help me out..
|
|
|
|
|
Sub PopulateBounded()
Dim ColumnName As String = "MyItems"
con='YOUR CONNECTION'
con.Open()
Dim SQL As String = "SELECT ..."
da='YOUR ADAPTER'
Dim dt As New System.Data.DataTable
da.Fill(dt_addcombo)
Dim Mycolumn As New DataGridViewComboBoxColumn()
Mycolumn.DataSource = dt
Mycolumn.DisplayMember = "..."
Mycolumn.ValueMember = "..."
Mycolumn.DataPropertyName = "..."
Mycolumn.Name = ColumnName
Mycolumn.HeaderText = "Header text"
datagridview1.Columns.Add(Mycolumn)
End Sub
Shay Noy
|
|
|
|
|
Thanks for your input
shaynoy wrote: da='YOUR ADAPTER'
Dim dt As New System.Data.DataTable
da.Fill(dt_addcombo)
Dim Mycolumn As New DataGridViewComboBoxColumn()
Can you plz tell me what is "dt_addsombo" is the above lines..
Also I am getting following error at
shaynoy wrote: datagridview1.Columns.Add(Mycolumn)
Overload resolution failed because no accessible 'Add' can be called with these arguments:
'Public Function Add(columnName As String) As System.Data.DataColumn': Value of type 'System.Windows.Forms.DataGridViewComboBoxColumn' cannot be converted to 'String'.
'Public Sub Add(column As System.Data.DataColumn)': Value of type 'System.Windows.Forms.DataGridViewComboBoxColumn' cannot be converted to 'System.Data.DataColumn'.
Regards
Nishkarsh
|
|
|
|
|
I had rename the variables to simplify the example I sent you but I forgot to rename this one.
change 'dt_addcombo' to 'dt'
Sorry
Shay Noy
|
|
|
|
|
Thanks..
I have another setting issue with the ComboBox in the DataGrid... I wanted the combo boxes to behaive like Dropdown Combo not DropDown List
Is there a way to change the drop Down property???
|
|
|
|
|
Hi Everyone,
I'm working on window application. I'm adding a set of new rows to datagrid using a datatable.
Once completed, i want to save all the added rows from datagrid to database.
How should i save it into database??
Can anyone advice me? Thanks in advanced.
Here is the codes:-
public Sub DataGrid()
myTable = New DataTable("Exam")
Dim Employee As DataColumn = New DataColumn("Employee")
Employee.DataType = System.Type.GetType("System.String")
myTable.Columns.Add(Employee)
Dim Score As DataColumn = New DataColumn("Score")
Score.DataType = System.Type.GetType("System.String")
myTable.Columns.Add(Score)
Dim ds As New DataSet
ds = New DataSet
ds.Tables.Add(myTable)
datagrid1.SetDataBinding(ds, "Exam")
end sub
Private Sub btnComplete_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnComplete.Click
Dim strQuery1 As String
strQuery1 = "Insert into MMExam (Employee,Score) values('" & DataTable.Rows(Employee) & "','" & DataTable.Rows(Score )& "')"
myConnection.Open()
myCommand = New SqlCommand(strQuery1, myConnection)
Try
ra = myCommand.ExecuteNonQuery()
myConnection.Close()
Me.Close()
Catch ex As Exception
myConnection.Close()
MessageBox.Show(ex.Message)
End Try
End Sub
thanks,
eunice
|
|
|
|
|
A DataGrid is used to show and edit the data in a DataSource, such as a DataTable or DataSet. You don't go from DataTable to DataGrid to database. You go from DataGrid - which shows and edits a DataTable/DataSet - which synchronizes changes with a Database.
From what you've posted, your code is pretty much spaghetti.
If you're adding records to an existing database, I'd start by creating a DataSet and DataAdapter with the proper SQL statement to retrieve the fields from the table that you're going to manipulate. Use it's FillSchema method to create a new DataTable object in your DataSet object. This will automatically setup your DataTable for your, mapping the columns in the database to the columns in the DataTable using the proper data types.
Then, you use a CommandBuilder (SqlCommandBuilder, OleDbCommandBuilder, ...) on the DataAdapter to create the SQL UPDATE, INSERT, and DELETE commands for the DataAdatper.
Then bind the DataGrid to that DataTable, make your changes, then use the DataAdapter's Update method to write the changes back to the database.
|
|
|
|
|
Hi.
I want to control a electronic lock using the parallel port and I don't know how to control it using VB .Net 2008. Can you teach me how to control the parallel port?
Thanks a lot.
Merry Christmas!
|
|
|
|
|
You need a 3rd party library to directly control the hardware, something akin to a device driver. You can find one such library and some example code here[^] and here[^].
|
|
|
|
|
Hi all
I am working on a chat application in vb.net. I can specify a IP address and send message to a computer where my application is installed and running.
But i want to populate the ip address ( system in the LAN where application is running)automatically as soon as the application starts, just like any messenger(where the name of online people display in bold).
A refresh button i want to put so that as soon a new user in different machine starts the application his IP gets displayed in the application window.
Thanks and Regards
Prakash Mishra(Banglore,India)
|
|
|
|
|
Prakash_Mishra wrote: But i want to populate the ip address ( system in the LAN where application is running)automatically as soon as the application starts, just like any messenger(where the name of online people display in bold).
You'll need a central server that all the clients check into when they start. This server would keep track of the IP's for each client and give them out to the clients when they check in.
|
|
|
|
|