|
I wish you to end soon your program ShabRaza.
Good night.
|
|
|
|
|
Hello
Are you having ID filds in DGV.If you having then u can easly send selected rows into another dgv on another form.
When you select that row then just get id of that row, and when return data button is clicked then add new row on other dgv and send value from one dgv to another dgv.
The another method is that check which row is select using selected = true. Create object of another form and access DGV using anohterformobj.Datagridview. and add selected records on another dgv.
Regards
DC
|
|
|
|
|
Actually their are several ways to do this depends upon the criteria and structure of the application
lets suppose you need to show
=-=-Item Code=-=-=-=-Item Name=-=-==-=-category Name=-=-=-=-=-=-Units=-=-=-=-=-=-Qty
on the Destination form then on your Search/Lookup Form you can have some other columns like
=-=-Item ID======Category ID-=-=-=-=--
but hide them along with your other columns and dont show them to the end user when user will select any row then it will bring with it that item id, category id etc.. take only Keys as hidden columns
you can take this id and then can make a query to get your desired results and can populate your fields,
will not recommend you to open Costly connections again and again means to go to the database and bring your information time to time
Dont bring information other then Keys in hidden columns because if their will be any change on that data lets say you had populated in your grid and some other user changed the item Name or some other information in this case you will have still old value in the grid so bring only the IDs as hidden column and then fetch your desired data from db
Best Of Regards,
SOFTDEV
Sad like books with torn pages, sad like unfinished stories ...
|
|
|
|
|
Hi all.
I am trying to check whether a process has terminated or not by its process id.
I put my code in a timer object to continuously check whether process has terminated or not.
code is :
Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick
If Process.GetProcessById(ProcessID).HasExited Then 'processId is publicly defined and doesn't store null value
Cursor = Cursors.Default
Timer1.Dispose()
msgbox("Process has been terminated")
End If
End Sub
but each time timer starts, it gives an "Access is Denied" error message at line
If Process.GetProcessById(ProcessID).HasExited Then
what should I do to check whether the process has terminated or not.
Thanks.
Gagan
|
|
|
|
|
Hi,
if you are logged in as a regular user and try to get information on a process that isn't yours, Windows will give you an "access denied" error (at least on Vista and 7, not sure for others). In general you have no rights on objects that don't belong to you.
BTW: An admin has no problems, Process.Exited does not need elevation.
|
|
|
|
|
Thanks Luc for your help but I already logged as "Computer Administrator"
(in Windows XP) but the same problem occurs all the time.
process.HasExited 'Access is Denied.
Is there any other way to check whether process has terminated or not, if yes then tell me.
Thanks.
Gagan
|
|
|
|
|
What process is it you want to check? Dit your app launch it?
Your code works fine for me checking my browser.
|
|
|
|
|
I am executing "cmd.exe" and getting its process id to check whether "cmd.exe" has terminated or not but all the time it gives the same "Access is Denied" error message.
|
|
|
|
|
Hi,
two suggestions:
1.
For processes that your app started, choose one of several Process.Start overloads that return a Process instance, so you don't need Process.GetProcessById()
2.
Rather than periodically checking Process.HasExited, you could have a thread (Thread, ThreadPool, BackgroundWorker) wait for its exit with Process.WaitForExit which also needs the process instance.
|
|
|
|
|
I have a table populated with details of people (Name, tel, address, etc.) Each record has a unique key. I want to fill a combobox with the names, but when a user clicks on the name I want to use the unique identifier to get the corresponding detail. Below is my code to fill the combobox. How should I change this so that the combobox also knows what the unique identifier is?
I am new to programming, so any other comments on my code would also be appreciated.
Thanks for any help.
Private Sub GetContactNames()
Dim SqlContactname As String _
= "SELECT _rtblPeople.idPeople, _rtblPeople.cDisplayName " _
& "FROM _rtblPeople, _rtblPeopleLinks " _
& "WHERE _rtblPeopleLinks.iDebtorID = @customercode " _
& "AND _rtblPeopleLinks.cModule = 'AR' " _
& "AND _rtblPeople.idPeople = _rtblPeopleLinks.iPeopleID"
Dim Sqlparam As SqlClient.SqlParameter
Sqlparam = New SqlClient.SqlParameter("@customercode", SqlDbType.Int)
Sqlparam.Value = My.Settings.CustomerCode
Using conn As New SqlConnection(CntString)
Try
conn.Open()
Dim MyCommand As New SqlCommand(SqlContactname, conn)
MyCommand.Parameters.Add(Sqlparam)
Dim datareader As SqlDataReader
datareader = MyCommand.ExecuteReader
While datareader.Read()
ContactNameField.Items.Add(datareader.Item("cDisplayName"))
End While
datareader.Close()
conn.Close()
Catch myerror As SqlException
MessageBox.Show("Error Connecting to Database: " & myerror.Message)
conn.Dispose()
End Try
End Using
End Sub
|
|
|
|
|
Hi,
you could create a little class describing an item in the combobox.
Then tell the ComboBox where the list of items is (DataSource), which property to use for displaying (DisplayMember) and which one for processing (ValueMember).
MSDN holds examples for all this.
|
|
|
|
|
OK, I think I managed to create the class and it seems to work, except when I have names in the combobox that are identical. Say I have values John(1), Paul(2), John(3). When I select the first John other fields on the form is refreshed using the correct value (1). When I select the second John it also works fine using the correct value (3). The problem is when I leave the comboxfield another SelectedIndexChange is fired and the value then changes to (1). When I select Paul I have no problem.
Here is the class I created - I copied the format from sample code:
Public Class myLookupClass
Private iID As Integer
Private sValue As String
Public Sub New(ByVal DisplayValue As String, ByVal ID As Integer)
iID = ID
sValue = DisplayValue
End Sub
Public Property GetLookup() As Integer
Get
Return iID
End Get
Set(ByVal value As Integer)
sValue = value
End Set
End Property
Public Overrides Function ToString() As String
'Return MyBase.ToString()
Return sValue
End Function
End Class
I populate the combobox like this
While datareader.Read()
ContactNameField.Items.Add( _
New myLookupClass((datareader.Item("cDisplayName")), _
(datareader.Item("idPeople"))))
End While
Any thoughts on were I am going wrong?
|
|
|
|
|
In some way, the names that you are showing (display values) should be unique. If there are going to be two or more the same, how will the user know which one he should pick?
In other words, if you solve that problem, you also won't have this problem.
My advice is free, and you may get what you paid for.
|
|
|
|
|
They would be unique most of the time, I am just trying to cover all possibilities. That is why I created the class to work with the ID of each field (which is unique). As the user selects a field, other fields on the form refresh to give them more info of the selected person so they will know who they selected even if the names are the same.
|
|
|
|
|
In that case you could use one of two workarounds:
1. The AchoiceWasMade boolean, to check whether the selected index was changed by the user. That way you circumvent the event firing twice.
or
2. Change the display value to include a number, for example the way you did in the original problem description: John (1) and John (2).
So you make the display value unique, and it would only make things clearer for the user.
My advice is free, and you may get what you paid for.
|
|
|
|
|
I like your first option - If I cant get it to work, i'll have to use the second option.
Thanks for the replies.
|
|
|
|
|
No problem.
P.S. The SelectedIndexChanged event may also fire when you start your application.
My advice is free, and you may get what you paid for.
|
|
|
|
|
I found a solution that works perfectly - instead of using SelectedIndexChange event, I used SelectionChangeCommitted event to trigger my refresh. So now it only refreshes when I actually click on a item in the combobox - which is exactly what i want.
|
|
|
|
|
Hello Every body,
I am trying to send data to server using post method. but this is showing "The Remote Server Returned an error :(411) Length Required". When i used get method to send data, then it is just send only 255 character.
i read that, using post method you can send unlimited data.
my data may be 255 character and i am sending data as a parameter like below.
Try
myUri = New Uri("https://www.mywebsite.com/apis/ConfirmContactUpdated.cfm?APIServiceTag=" & APIServiceTag.Trim & "&APISessionTag=" & AutheniticateSession & "&APIContactTag=" & myds.Tables(0).Rows(i)("tbl_All_Contact_List.ServiceTag").ToString.Trim & "&APIContactUpdatedBoolean=False" & "&APIContactUpdatedDateTime=" & myds.Tables(0).Rows(i)("tbl_All_Contact_List.LastUpdate").ToString.Trim & "&APIUpdateNotesBoolean=True&APINotesLastChangedDateTime=" & myds.Tables(0).Rows(i)("tbl_All_Contact_List.NotesLastUpdate").ToString.Trim & "&APINotesText=" & myds.Tables(0).Rows(i)("Updated_Note").ToString.Trim)
Dim reader As StreamReader
request = DirectCast(Net.WebRequest.Create(myUri), HttpWebRequest)
request.Method = "POST" '"GET"
request.ContentLength = myds.Tables(0).Rows(i)("Updated_Note").ToString.Trim.Length + 100
Try
response = DirectCast(request.GetResponse(), HttpWebResponse)
reader = New StreamReader(response.GetResponseStream())
Catch ex As System.Exception
MsgBox(ex.Message.ToString)
End Try
Can anybody send me example with source code so that i can check where i m wrong. Or plese review this code.
I am using vb.net 2005.
Thakns in advancd.
Regards
DC
|
|
|
|
|
May be for you can be interesting to read this:
http://www.checkupdown.com/status/E411.html
|
|
|
|
|
hello,
First of all thanks for reply...
I have solve this problem and solution is
Dim oWeb As New System.Net.WebClient()
oWeb.Headers.Add("Content-Type", "application/x-www-form-urlencoded")
Try
Dim bytRetData As Byte() = oWeb.UploadData(myUri, "POST", requestBytes)
Catch ex As System.Exception
MsgBox(ex.Message.ToString)
Finally
oWeb.Dispose()
End Try
Regards
DC
|
|
|
|
|
OK, I have multiple controls hidden on my form. I want to show them, based on the combo box selection. In other words if the user selects SelectedIndex 0, then I want to show the first row of controls, SelectedIndex 1, the first row and the second row of controls. I'm having trouble doing this in an efficient manner. I know I can just bludgeon the code into doing this by just typing my code over and over again, but I feel this can be achieved more efficiently and I'm looking for help. I'm new to programming and I'm trying to learn by building my own project. Thank you, here is an example of the code I have so far...
'Show the rows selected based on the number chosen by the user
Select Case CInt(cboFundSelector.SelectedIndex)
Case 0
lblUnits.Visible = True
lblPrice.Visible = True
txtNameofFund1.Visible = True
txtUnits1.Visible = True
txtPrice1.Visible = True
lblFund1Total.Visible = True
Case 1
lblUnits.Visible = True
lblPrice.Visible = True
txtNameofFund1.Visible = True
txtUnits1.Visible = True
txtPrice1.Visible = True
lblFund1Total.Visible = True
txtNameofFund2.Visible = True
txtUnits2.Visible = True
txtPrice2.Visible = True
lblFund2Total.Visible = True
|
|
|
|
|
Your best bet is to do this with a loop. Create some sort of template for rows of data, such as a gridview. Then once you know how many rows to show, iterate over that number of rows and make them visible.
Christian Graus
Driven to the arms of OSX by Vista.
Read my blog to find out how I've worked around bugs in Microsoft tools and frameworks.
|
|
|
|
|
Their are several ways to do this
1)
Use the Tag Property of the controls let's suppose Put "1" in controls where your case is 1
and put the following code
For Each Control As System.Windows.Forms.Control In Me.Controls
If TypeOf Control Is TextBox Then
If Control.Tag = "1" Then
Control.Visible = False
End If
End If
Next
2).
You can also use the GroupBox Control and can set its visibility to true and False if your controls are in one order/Sequence rather then doing whole controls
Best Of Regards,
SOFTDEV
Sad like books with torn pages, sad like unfinished stories ...
|
|
|
|
|
A better way would be to group the controls in different panels and toggle the visibility of panel according to the selection.
|
|
|
|