|
Hello every one
Can any one plz let me know how to find the row index of selected cell / current cell
I have to add some text in the current or selected row's specific column once the index of the combobox (outside the grid) is changed by the user.
Regards
Nishkarsh
|
|
|
|
|
If you are using a DataGridView or something similar you can usually access the SelectedCells() property. SelectedCells(0).RowIndex gives you the row index of the first selected cell.
Volker Weichert
|
|
|
|
|
hi all
thanks for previous reply.
I have another qurey.I serched lot for this ,but did't get proper solution.
Actully in my application m using vb.net2003 and access.On one form I have used tabcontrol with 2 tabpages.On 1st tabpage there is list view.I wt i want is ,when i click on any item the text of that item should display on textbox of another tabpages.To get text value of item i wrote several code like
[code]
Dim item As ListViewItem
Dim column As Integer
MessageBox.Show(item.SubItems(0).Text)
or
MsgBox(LstRecord.SelectedItems(1).Text)
or
MsgBox(LstRecord.SelectedItems(1).SubItems(2).Text)
or
l1.Text = LstRecord.SelectedItems(3).Text.ToString
or
MsgBox(e.Item.ToString)
[/code]
it fails every time.Plz help me.
poonam
|
|
|
|
|
What error do you get?
The following could be issues with your code:
poonams wrote: MessageBox.Show(item.SubItems(0).Text)
item is not instantiated
poonams wrote: MsgBox(LstRecord.SelectedItems(1).Text)
or
MsgBox(LstRecord.SelectedItems(1).SubItems(2).Text)
or
l1.Text = LstRecord.SelectedItems(3).Text.ToString
Most likely the maximum array subscript of SelectedItems is less than 1, ie., you have only selected 1 item from the list.
|
|
|
|
|
I currently using VB.NET and RichTextBox Control, when i want to save the data it works properly, but why the cursor move to the top?
Thanks
Socheat
|
|
|
|
|
Try some thing like this which i use for the multi line text box
txt_box.SelectionStart = 0
txt_box.SelectionStart = Len(txt_box.Text)
txt_box.ScrollToCaret()
Good luck
|
|
|
|
|
Your code i think it not work properly because the cursor will be go to buttom of TextBox control,
I mean whereever cursor focus after saved it still focus the same place.
Thanks
Socheat
|
|
|
|
|
I have made a small software which requires .Net framework 2.0 and Sql server Express 2005.I want to make a setup file which automatically installs these two components.
How can i achieve this??
|
|
|
|
|
You can use some tools to create the setup.
|
|
|
|
|
There are tools like INO setup which are under GNU license..
You can download them...
I had used it to do some...
|
|
|
|
|
I have to take back up and restore my database in VB.NET2003 & SQL SERVER 2000. I don't know back up & restore coding. Please send me the coding.
_vaani_
|
|
|
|
|
Hi Vaani,
I do not have expertise on restoring SQL Server database programmatically. Howerver, you may try following code snippet to take backup of a SQL SERVER database from a remote machine. You will need to compile it and change the values to reflect your server.
BEGIN CODE
Imports System
Imports System.Data
Imports System.Collections
Imports Microsoft.SqlServer.Management.Common
Imports Microsoft.SqlServer.Management.Smo
Class Program
Private Shared Sub Main(ByVal args As String())
Dim bdi As New BackupDeviceItem("AdventureWorks.bak", DeviceType.File)
Dim bu As New Backup()
bu.Database = "AdventureWorks"
bu.Devices.Add(bdi)
bu.Initialize = True
AddHandler bu.PercentComplete, AddressOf Backup_PercentComplete
AddHandler bu.Complete, AddressOf Backup_Complete
' add percent complete and complete event handlers
Dim server As New Server("localhost")
bu.SqlBackup(server)
Console.WriteLine(Environment.NewLine + "Press any key to continue.")
Console.ReadKey()
End Sub
Protected Shared Sub Backup_PercentComplete(ByVal sender As Object, ByVal e As PercentCompleteEventArgs)
Console.WriteLine(e.Percent + "% processed.")
End Sub
Protected Shared Sub Backup_Complete(ByVal sender As Object, ByVal e As ServerMessageEventArgs)
Console.WriteLine(Environment.NewLine + e.ToString())
End Sub
End Class
END CODE
I hope this would be helpful .
Regards,
John Adams
ComponentOne LLC
|
|
|
|
|
Hi all,
I'm currently doing a contract and vendor windows form application.
I have no problem creating reports, i.e listing contracts and vendors by their specialisation.
But now, I have one problem - I do not know how to do a report which list contracts due for renewal in 3 months. The thing is I have already did a search function in a form which would list the contracts due for renewal in 3 months, using the query builder(which reflects under ContractTableAdapter). However, my previous reports are created by drag and drop of dataset's attributes into report designer (dragged Toolbox's ReportViewer and created a new report).
For contracts due for renewal, I do not have any dataset to drag and drop. (?)
My "Contract" table containing the following fields:
Contract_ID INT NOT NULL,
Vendor_ID INT NOT NULL,
DateStart datetime,
DateDue datetime,
PRIMARY KEY(Contract_ID),
FOREIGN KEY (Vendor_ID) REFERENCES Vendor(Vendor_ID)
I hope I convey what I wanted to say correctly. Any help is greatly appreciated. Thanks!
telly
p.s I already an alternative in mind, which is done not really in a report way.
|
|
|
|
|
How are you creating reports ? It sounds to me like you've got to the point of needing to learn SQL.
Christian Graus - Microsoft MVP - C++
"also I don't think "TranslateOneToTwoBillion OneHundredAndFortySevenMillion FourHundredAndEightyThreeThousand SixHundredAndFortySeven()" is a very good choice for a function name" - SpacixOne ( offering help to someone who really needed it ) ( spaces added for the benefit of people running at < 1280x1024 )
|
|
|
|
|
Hi Graus,
Thanks for the reply.
But what is wrong with the SQL (btw, the SQL statements are used for MSSQL)? Don't mind can you say in more detail instead of just a one-liner. I really do not know where the SQL went wrong. I'm currently a beginner in SQL and VB.net but I do make an attempt in trying before asking, and learnt along the way.
I created reports using this. I followed the steps exactly (the only difference is probably the database attributes).
Meticulous advise, please? Appreciated. thanks.
telly
|
|
|
|
|
It sounds to me like you're creating reports by dragging and dropping in some tool. SQL functions like GetDate allow you to write SQL that checks a date against a known value, but you would need to write your own SQL for that, not use a tool that generates it.
I have never used the report viewer control, I didn't know it existed.
Christian Graus - Microsoft MVP - C++
"also I don't think "TranslateOneToTwoBillion OneHundredAndFortySevenMillion FourHundredAndEightyThreeThousand SixHundredAndFortySeven()" is a very good choice for a function name" - SpacixOne ( offering help to someone who really needed it ) ( spaces added for the benefit of people running at < 1280x1024 )
|
|
|
|
|
I'm assuming you use the crystal reports version that is embedded in visual studio 2005
since you already are able to display the records on a form I'm also asuming you can find the sql query needed for this
if both asumtions are correct this might be a way to do what you want:
you create a new report (add --> crystal report)
in the database expert of that report (tab data) you can select you'r database then you get the option to add a table or a command
choose command
now you can enter an sql query wich will be used to create the report
do some layout on the report as you see fit
then on you'r form do the following:
<br />
sub btnprint.click<br />
Dim rpt As New ProjectVoorblad()<br />
rpt = reconnectreport(rpt)<br />
Dim dt As New DataTable()<br />
dt = FILLDTWITHYOURSQLQUERY<br />
rpt.SetDataSource(dt) 'this will only work if there is only 1 command and 0 tables in the report <br />
crvMain.ReportSource = rpt 'crvmain = crystal reports vieuwer<br />
end sub<br />
<br />
Private Function reconnectreport(ByVal report As ReportDocument) As ReportDocument<br />
Dim connection As IConnectionInfo<br />
Dim oldServerName As String = report.DataSourceConnections(0).ServerName<br />
Dim newServerName As String = sservername<br />
Dim oldDatabaseName As String = report.DataSourceConnections(0).DatabaseName<br />
Dim newDatabaseName As String = sdbname<br />
Dim userID As String = susername<br />
Dim password As String = spass<br />
report = report<br />
' Change the server name and database in main reports<br />
For Each connection In report.DataSourceConnections<br />
If (String.Compare(connection.ServerName, oldServerName, True) = 0 _<br />
And String.Compare(connection.DatabaseName, oldDatabaseName, True) = 0) Then<br />
' SetConnection can also be used to set new logon and new database table<br />
report.DataSourceConnections(oldServerName, oldDatabaseName).SetConnection( _<br />
newServerName, newDatabaseName, userID, password)<br />
End If<br />
Next<br />
' Change the server name and database in subreports<br />
Dim subreport As ReportDocument<br />
For Each subreport In report.Subreports<br />
For Each connection In subreport.DataSourceConnections<br />
If (String.Compare(connection.ServerName, oldServerName, True) = 0 _<br />
And String.Compare(connection.DatabaseName, oldDatabaseName, True) = 0) Then<br />
' SetConnection can also be used to set new logon and new database table<br />
subreport.DataSourceConnections(oldServerName, oldDatabaseName).SetConnection( _<br />
newServerName, newDatabaseName, userID, password)<br />
End If<br />
Next<br />
Next<br />
Return report<br />
End Function<br />
the reconnectfunction reconnects you'r report to the correct database (if it changed)
if the connection to you'r database never changes you don't really need to do this
hope this helps
if you need more explenation let me know
If my help was helpfull let me know, if not let me know why.
The only way we learn is by making mistakes.
|
|
|
|
|
Hi TD, thanks for the reply.
Your assumptions:
1) I use ReportViewer (am using Microsoft Visual Studio 2005 btw) from the Toolbox to create reports. I do not use Crystal Report (I just use Windows Form).
2) Do you mean the SQL select query for listing contracts due for renewal in 3 months? If so, yes I know the query.
SELECT Contract_ID<br />
FROM Contracts<br />
WHERE DateDue BETWEEN GetDate() AND DateAdd(mm, 3, GetDate())
Do you have any idea how to do a report which list contracts due for renewal in 3 months (which is not one of the database attribute)?
Previously how I created my report(drag and drop):
like this
Can you help me please? Thanks in advance.
telly
|
|
|
|
|
first sorry for the late reply but I didn't have access to the internet this weekend
for you'r problem:
I'v never used your way of creating reports but from the looks of it its some sort of spin-off from crystal reports.
If you want to continue using this way my sugestion would be to create a dummy dataset (with you'r sql in it) then before you call the report you fill the dataset with the correct data that way you can keep using this drag and drop methode
I think that with the sql query you provided you don't even have to fill the dataset it will always be correct (if the table doesn't change and the date to look from is always the current date) so you should be able to create the dataset and use it like any other
if that doesn't work I suggest looking into crystal reports it will accomplish alot more and is free (at least the one embedded in visual studio is)
If my help was helpfull let me know, if not let me know why.
The only way we learn is by making mistakes.
|
|
|
|
|
Hi everyone,
Here I have a strange problem.
I am working on a console application.
I use the following code to print : Welcome
console.writeline("Welcome")
Now I want to print: "Welcome"
I want to print it with quotes. but ,
console.writeline(" "Welcome" ") gives me an error.
So, what to do to print a word with quotes??
Thanks For any help,
Dan
|
|
|
|
|
Not strange at all. How would the compiler know when " means a quote you want to print, or when it means a quote, in the usual sense ?
console.writeline("\"Welcome\"")
Assuming it works the same as C#. f not, you'll have to google to find the VB syntax.
Christian Graus - Microsoft MVP - C++
"also I don't think "TranslateOneToTwoBillion OneHundredAndFortySevenMillion FourHundredAndEightyThreeThousand SixHundredAndFortySeven()" is a very good choice for a function name" - SpacixOne ( offering help to someone who really needed it ) ( spaces added for the benefit of people running at < 1280x1024 )
|
|
|
|
|
For VB you can use console.writeline("""Welcome""")
|
|
|
|
|
|
I have a question. I need to know if it would be better for me to use a fill by method or a binding source.
Here is what I am doing.
I have a check box and 2 combo boxes for each day of the week. The user would check the Monday check box and then choose a time of day such as 6:00PM in the from time and 10:00PM in the to time combo box. Once the user selects the times the combo boxes populate these times from a database table and sets the selected value from another table that holds the time they selected.
Can you tell me what would be better to do? Should I use a FillBy Method or a Binding Source? When I first learned VB.Net in college about 2 years ago I just wrote a query and used a data adapter. I am new to VB.NET 2005 and have very little experience in VB.
When I added the () to (BindingSource) Dim instance As BindingSource() the instances are getting a blue squigly line. Why?
Here is the code I am writing using a Binding Source.
Dim bsMonStoreSched As BindingSource()<br />
Dim bsTuesStoreSched As BindingSource()<br />
Dim bsWedStoreSched As BindingSource()<br />
Dim bsThurStoreSched As BindingSource()<br />
Dim bsFriStoreSched As BindingSource()<br />
Dim bsSatStoreSched As BindingSource()<br />
Dim bsSunStoreSched As BindingSource()<br />
<br />
' create table adapter objects<br />
Dim hoursTableAdapter As New theLessonProgramDataSetTableAdapters.tbl_hoursTableAdapter<br />
Dim schedTableAdapter As New theLessonProgramDataSetTableAdapters.tbl_store_schedTableAdapter<br />
<br />
' create data set objects<br />
Dim lpDataSet As New theLessonProgramDataSet()<br />
<br />
' create dataTables<br />
Dim dtHours, dtSched As New DataTable()<br />
<br />
' create binding source<br />
Dim bsHours As BindingSource<br />
Dim bsStoreSched As BindingSource<br />
<br />
' fill the dataTables<br />
Try<br />
hoursTableAdapter.Fill(lpDataSet.tbl_hours)<br />
schedTableAdapter.Fill(lpDataSet.tbl_store_sched)<br />
Catch err As Exception<br />
MessageBox.Show(err.Message)<br />
End Try<br />
<br />
dtHours = lpDataSet.tbl_hours<br />
dtSched = lpDataSet.tbl_store_sched<br />
<br />
' Set the binding Source for mon - sun<br />
bsMonStoreSched.DataSource = dtSched<br />
bsTuesStoreSched.DataSource = dtSched<br />
bsWedStoreSched.DataSource = dtSched<br />
bsThurStoreSched.DataSource = dtSched<br />
bsFriStoreSched.DataSource = dtSched<br />
bsSatStoreSched.DataSource = dtSched<br />
bsSunStoreSched.DataSource = dtSched<br />
<br />
' Filter the items to show results.<br />
bsMonStoreSched.Filter = "ss_day = 'Monday'"<br />
bsTuesStoreSched.Filter = "ss_day = 'Tuesday'"<br />
bsWedStoreSched.Filter = "ss_day = 'Wednesday'"<br />
bsThurStoreSched.Filter = "ss_day = 'Thursday'"<br />
bsFriStoreSched.Filter = "ss_day = 'Friday'"<br />
bsSatStoreSched.Filter = "ss_day = 'Saturday'"<br />
bsSunStoreSched.Filter = "ss_day = 'Sunday'"<br />
<br />
' fill the Mon - Sun combo boxes with the hours<br />
cboLSMonFrom.DataSource = dtHours<br />
cboLSMonFrom.DisplayMember = "h_time"<br />
cboLSMonFrom.ValueMember = "h_id"<br />
cboLSTuesFrom.DataSource = dtHours<br />
cboLSTuesFrom.DisplayMember = "h_time"<br />
cboLSTuesFrom.ValueMember = "h_id"<br />
cboLSWedFrom.DataSource = dtHours<br />
cboLSWedFrom.DisplayMember = "h_time"<br />
cboLSWedFrom.ValueMember = "h_id"<br />
cboLSThurFrom.DataSource = dtHours<br />
cboLSThurFrom.DisplayMember = "h_time"<br />
cboLSThurFrom.ValueMember = "h_id"<br />
cboLSFriFrom.DataSource = dtHours<br />
cboLSFriFrom.DisplayMember = "h_time"<br />
cboLSFriFrom.ValueMember = "h_id"<br />
cboLSSatFrom.DataSource = dtHours<br />
cboLSSatFrom.DisplayMember = "h_time"<br />
cboLSSatFrom.ValueMember = "h_id"<br />
cboLSSunFrom.DataSource = dtHours<br />
cboLSSunFrom.DisplayMember = "h_time"<br />
cboLSSunFrom.ValueMember = "h_id"<br />
<br />
' bind the list controls selected value property<br />
cboLSMonFrom.DataBindings.Add("SelectedValue", bsMonStoreSched, "ss_id")<br />
cboLSTuesFrom.DataBindings.Add("SelectedValue", bsTuesStoreSched, "ss_id")<br />
cboLSWedFrom.DataBindings.Add("SelectedValue", bsWedStoreSched, "ss_id")<br />
cboLSThurFrom.DataBindings.Add("SelectedValue", bsThurStoreSched, "ss_id")<br />
cboLSFriFrom.DataBindings.Add("SelectedValue", bsFriStoreSched, "ss_id")<br />
cboLSSatFrom.DataBindings.Add("SelectedValue", bsSatStoreSched, "ss_id")<br />
cboLSSunFrom.DataBindings.Add("SelectedValue", bsSunStoreSched, "ss_id")
|
|
|
|
|
AAGTHosting wrote: Dim bsMonStoreSched As BindingSource()
Dim bsTuesStoreSched As BindingSource()
Dim bsWedStoreSched As BindingSource()
Dim bsThurStoreSched As BindingSource()
Dim bsFriStoreSched As BindingSource()
Dim bsSatStoreSched As BindingSource()
Dim bsSunStoreSched As BindingSource()
First, let me say that you have no reason to use this many bindingsources for what your code is suggesting you're doing. One is enough.
Second, seriously, pick up a book on VB.NET for beginners. These lines mearly declare a variable that CAN hold a BindingSource object. You never actually created any BindSource objects because you're missing the New keyword in the Dim statement.
Dim bsTuesStoreSched As New BindingSource()
The problem you run into with this code is that as soon as these variables fall out of scope, the BindingSources will be destroyed. You have to declare these in class scope, not method scope.
|
|
|
|