|
Something like:
Public Function GetGridData(ByVal value as Object) As Object
For Each dr as DAtaGridViewRow In dgv.Rows
If dr(0).Cells.Value = value Then
Return dr(1).Cells.Value
End If
Next
End Function
I don't speak Idiot - please talk slowly and clearly
'This space for rent'
Driven to the arms of Heineken by the wife
|
|
|
|
|
Thanks Andy. But one thing, If My number of rows are 5000, then will this search be fast?
Because I have to run this search 2-3 times in my complete project.
|
|
|
|
|
hi,
i have a textbox and i want to copy the contents of the textbox into a .txt file.
my current code works however when i open the .txt file it comes up saying
"System.Windows.Forms.TextBox, Text:" then what i actually want in the .txt file
is there any way where i can stop this from happening and just displaying what i want in the text box in the .txt file?
code used
objWriter.WriteLine(TextBox1)
objWriter.Close()
many thanks
|
|
|
|
|
offroaderdan wrote: objWriter.WriteLine(TextBox1)
Can you see anything wrong here? You aren't writing the text to file.
It's not necessary to be so stupid, either, but people manage it. - Christian Graus, 2009 AD
|
|
|
|
|
at the beggining i have
dim serial as string = ("TEST.txt")
|
|
|
|
|
Doesn't the TextBox1 object you have expose a Text property??
Seriously...pick up a beginners book on VB.NET. You're showing us you don't understand the basics of the language, the basic .NET object model, and a bunch of other stuff that makes it very difficult for you to understand the answers you're getting. This is just another example of it.
|
|
|
|
|
Hi,
File open from Office Automation, is it possible to dock the word document inside the panel4?
Dim mf As Microsoft.Office.Interop.Word.Application
mf.Documents.Open("C:\Sample\My_Exp.doc")
blah...blah...blah....
mf.visible =true
??????????????
Thanks
|
|
|
|
|
|
Hi Dave,
Anyhow many of your guidences are more powerful and helped me at right moments. Atleast I can say THANKS here, and I will pray for your piece.You have to live good.
|
|
|
|
|
There is a article here on CP in C#, WinWordControl[^] that you could use as a basis for converting to your needs.
|
|
|
|
|
hello,
my last question was basically on the lines of how do i use the command prompt in vb.net to recieve information. I want to try and get the serial number of command prompt (wmic bios get serialnumber - in command prompt) this will then bring up a serial number
someone answered my question with a line of code that proably does work however ia m having trouble incorprating it to do what i want it to do. I want to copy the serial number fro the command prompt into a text box?
here is my code
Imports System.Management
Public Class Form1
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim SerialNumber As System.Management.ManagementClass
Dim Win32_BIOS As System.Management.ManagementObjectSearcher
Select Case SerialNumber FROM Win32_BIOS ' surely FROM should be in blue???
End Select
textbox1.text = SerialNumber 'copys serial number from the Win32_bios into the txtdocument
End Sub
End Class
i am a bit of a beginner/intermediate but it would really mean allot if i could get this working
many thanks
|
|
|
|
|
offroaderdan wrote: Select Case SerialNumber FROM Win32_BIOS
Oh no. It takes a bit more code. I only have a C# example showing all non-null entries in Win32_BIOS:
ManagementObjectSearcher searcher=
new ManagementObjectSearcher("SELECT * FROM Win32_BIOS");
ManagementObjectCollection results=searcher.Get();
foreach (ManagementObject result in results) {
PropertyDataCollection pdc=result.Properties;
foreach (PropertyData pd in pdc) {
string name=pd.Name;
object obj=pd.Value;
if (obj!=null) output(name+" = \""+obj.ToString()+"\"");
}
}
Luc Pattyn
I only read code that is properly indented, and rendered in a non-proportional font; hint: use PRE tags in forum messages
|
|
|
|
|
thanks for the reply!!!
Umm i've had ago at trying to write what you put n c into vb.net however i have no idea what code to use?
as i have only ever coded in vb.net
Where do i use the
Select Case SerialNumber FROM Win32_BIOS ' surely FROM should be in blue???
End Select
??
Many thanks
|
|
|
|
|
in the ManagementObjectSearcher constructor, as I did.
Luc Pattyn
I only read code that is properly indented, and rendered in a non-proportional font; hint: use PRE tags in forum messages
|
|
|
|
|
thanks again for the super quick reply
umm this is how far i have got and then i get stuck
Imports System.management
Public Class Form1
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim SerialNumber As New Management.ManagementObjectSearcher("serialnumber Win32_BIOS")
Dim pd As String
For Each management.ManagementObject result in result
PropertyDataCollection(pdc = results.properties)
for each propertyData pd in pdc)
if (obj!null) output(name+" =\"+obj.tostring()+"/") then
textbox1.text = SerialNumber
End If
Next
End Sub
End Class
this don't work it doesn't like the if statement and the for statement either
|
|
|
|
|
all it takes is for you to understand how it works (see documentation and my example), then write code accordingly in the language of your choice.
And why did you modify the SQL-like statement in the ManagementObjectSearcher?
I will no longer hold your hand, please learn to help yourself.
Luc Pattyn
I only read code that is properly indented, and rendered in a non-proportional font; hint: use PRE tags in forum messages
|
|
|
|
|
that is the problem i don't understand c code. I am just about alright with vb.net code however i was trying to use you r code which u kindly wrote but i really haven't got a clue to writting it in vb.net. The only reason that i had to change the managemt SQL into "serialnumber Win32_BIOS" was because it didn't like "serialnumber" from "win32_BIOS"
I thank you for your work however i don't know c so would you be able to help me transfer it to vb.net?
many thanks
|
|
|
|
|
That's because it's not supposed to be in blue at all. That SELECT statement was supposed to be specified in the parameters of the objectsearcher class, not as a stand-alone statement. When I told you to look at the example in the link that I gave you, I would have thought that is was very obvious where that statement goes. I mean, in the example, there is a statement almost exactly like it.
|
|
|
|
|
offroaderdan wrote: Dim SerialNumber As New Management.ManagementObjectSearcher("serialnumber Win32_BIOS")
should be
Dim SerialNumber As New Management.ManagementObjectSearcher("SELECT SerialNumer from Win32_BIOS")
Then you can get rid of the contents of that loop and replace them with some simple code to display result 's SerialNumber property.
|
|
|
|
|
awsome thanks 0x3xc0
works now
|
|
|
|
|
I want to filter datagridview using 2 textboxes which filters the DGV according to the values entered in them. For example:
Suppose i have following dgv and
There is nametextbox where i type in "V" and i get following results.
Name Mobile
----- ------
Vikki 9861054321
Vinni 9546743243
Valter 3211243 etc...
Now i type into mobiletextbox "9" and i get following results:
Name Mobile
----- ------
Vikki 9861054321
Vinni 9546743243
and when i type "5" i.e. it becomes "95" and then i get following results :
Name Mobile
----- ------
Vinni 9546743243
For which i pass the following code in the text change event of both textboxes:
ClientProfileBindingSource.Filter = String.Format("Name LIKE '{0}%' AND Mobile LIKE '{1}%'", NameTextBox.Text, MobileTextBox.Text)
But this aint giving me results.. any thoughts on this?
|
|
|
|
|
Hi,
I have added an unbound checkbox column to my DGV. I have two questions on handling it:
1. How to have a checkbox on this Column header, which on checking must check all the rows in the DGV and vice versa?
2. How do i know what rows are selected?
Please help.
|
|
|
|
|
Take a look at this[^], from a quick look it seems to solve both your questions. It is in C#, unfortunately, but the syntax is sufficiently close to VB that you might well be able to understand it.
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.”
|
|
|
|
|
Hi
I am passing the following code to insert values in my DB table directly:
Private Sub SaveButton_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles SaveButton.Click
Using connection As New SqlClient.SqlConnection("Data Source=.\SQLEXPRESS;AttachDbFilename=D:\ProjectMW\MachineWale\MachineWale\DatabaseMW.mdf;Integrated Security=True;User Instance=True")
Using command As New SqlClient.SqlCommand("INSERT INTO [MachineProfile] ([MachineID], [Category], [Type], [Brand], [Model], [Quantity], [SalePrice], [RentalRate], [ListingDate], [Agent], [Availability], [PurchaseDate], [Kmsrun], [HoursRun], [ChasisNo], [EngineNo], [OtherSpec], [WebEntry], [Ownership]) VALUES (@MachineID, @Category, @Type, @Brand, @Model, @Quantity, @SalePrice, @RentalRate, @ListingDate, @Agent, @Availability, @PurchaseDate, @Kmsrun, @HoursRun, @ChasisNo, @EngineNo, @OtherSpec, @WebEntry, @Ownership) where [MachineID] = '" & TextBox1.Text & "'", connection)
command.Parameters.AddWithValue("@MachineID", TextBox1.Text)
command.Parameters.AddWithValue("@Category", ComboBox2.Text)
command.Parameters.AddWithValue("@kmsrun", TextBox10.Text)
command.Parameters.AddWithValue("@Type", ComboBox3.Text)
command.Parameters.AddWithValue("@Brand", ComboBox7.Text)
command.Parameters.AddWithValue("@Model", ComboBox8.Text)
command.Parameters.AddWithValue("@Quantity", TextBox7.Text)
command.Parameters.AddWithValue("@SalePrice", TextBox17.Text)
command.Parameters.AddWithValue("@RentalRate", TextBox18.Text)
command.Parameters.AddWithValue("@ListingDate", TextBox19.Text)
command.Parameters.AddWithValue("@Agent", ComboBox6.Text)
command.Parameters.AddWithValue("@Availability", ComboBox4.Text)
command.Parameters.AddWithValue("@PurchaseDate", DateTimePicker1.Value)
command.Parameters.AddWithValue("@HoursRun", TextBox11.Text)
command.Parameters.AddWithValue("@ChasisNo", TextBox12.Text)
command.Parameters.AddWithValue("@EngineNo", TextBox13.Text)
command.Parameters.AddWithValue("@OtherSpec", TextBox15.Text)
command.Parameters.AddWithValue("@WebEntry", ComboBox5.Text)
command.Parameters.AddWithValue("@Ownership", ComboBox1.Text)
connection.Open()
command.ExecuteNonQuery()
MsgBox("Updated")
End Using
End Using
End Sub
But i am getting this error after executing as:
Incorrect syntax near the keyword 'where'.
What could be possibly wrong?
LuxCoder
|
|
|
|
|
Try changing your command to:
Using command As New SqlClient.SqlCommand("INSERT INTO [MachineProfile] ([MachineID], [Category], [Type], [Brand], [Model], [Quantity],
[SalePrice], [RentalRate], [ListingDate], [Agent], [Availability], [PurchaseDate], [Kmsrun], [HoursRun], [ChasisNo], [EngineNo], [OtherSpec], [WebEntry],
[Ownership]) VALUES (@MachineID, @Category, @Type, @Brand, @Model, @Quantity, @SalePrice, @RentalRate, @ListingDate, @Agent, @Availability, @PurchaseDate,
@Kmsrun, @HoursRun, @ChasisNo, @EngineNo, @OtherSpec, @WebEntry, @Ownership) where [MachineID] = <big>@MachineID</big>", connection)
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.”
|
|
|
|
|