|
benny777ex wrote: I want to read the selected line with a text box, so I wrote:
Display.Text = JobList.Items.Item(LineNumber.Text).ToString
there are 2 textboxs: Display.Text, LineNumber.Text
and 1 listbox: JobList
hi I have another question,
Like I said, I want to read the selected line with textbox.
how to highlight the line in the listbox?
or is it possible to do some text change, such as make it bold,
or add some extra text like:
">>" + the line in the list box + "<<"
in the line in the listbox?
Please Help,
Thanks
Benny
Im using:
Windows XP Professional SP2
Microsoft Visual Basic 2005 (.NET)
|
|
|
|
|
use the following framework base class and it's functions
Imports Microsoft.VisualBasic.Compatibility.VB6
getitemdata
setitemdata
Sonia Gupta
Soniagupta1@yahoo.co.in
|
|
|
|
|
Thanks for reply
I had imported Microsoft.VisualBasic.Compatibility.VB6.
but... how to use them?
Benny
Im using:
Windows XP Professional SP2
Microsoft Visual Basic 2005 (.NET)
|
|
|
|
|
NO DON'T USE THAT PLEASE! That is a bad habit, to form a dependency on old vb6 methods, you should learn the new way because those methods will be phased out, most likely in the next edition. Do this:
me.listbox1.selectedindex = 'whatever number between 0 and listbox1.count - 1 or a variable
Posted by The ANZAC : "WWBD, What Would Buffy Do?" : "I don't know man, she's stronger than me"
|
|
|
|
|
Thanks again
I used your way, it works beautifully.
Benny
Im using:
Windows XP Professional SP2
Microsoft Visual Basic 2005 (.NET)
|
|
|
|
|
Your welcome, anytime.
Posted by The ANZAC : "WWBD, What Would Buffy Do?" : "I don't know man, she's stronger than me"
|
|
|
|
|
I have a datagridview control on the form and I want to let the user to pick a table and popular the table to the datagridview. The codes I have that work except, everytime you populate the datagridview with a different table, it maintain the old table columns.
Here is my codes
Dim mycommand As New SqlClient.SqlCommand<br />
mycommand.Connection = myConn<br />
Dim TableName As String = ComboBox2.SelectedItem<br />
mycommand.CommandText = "Select * from " & TableName<br />
myConn.Open()<br />
Try<br />
da = New SqlClient.SqlDataAdapter(mycommand)<br />
ds.Clear()<br />
da.Fill(ds)<br />
Dim dt As New DataTable<br />
dt = ds.Tables(0)<br />
DataGridView1.DataSource = dt<br />
<br />
Catch ex As Exception<br />
Debug.Print(ex.ToString())<br />
MsgBox(ex.ToString)<br />
Finally<br />
myConn.Close()<br />
End Try<br />
I thought that must be something very simple that I'm missing.
|
|
|
|
|
Clear the grid views columns before assigning the new datasource.
--
"Keyboard not found. Press < F1 > to RESUME. "
Source unknown (appears in many common BIOSes as a real error message)
|
|
|
|
|
Is there a way in .net to automatically run a task? I thought I once saw something about a pause or wait feature you can wait for so many milliseconds. And, is this plausible? Another question I have is, is there a way to see when a file is updated? (I want to open a file and read it but I only want to read it if it has been updated.
|
|
|
|
|
1 - you're talking about a timer
2 - there is a file watcher class, yes.
Christian Graus - Microsoft MVP - C++
"I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )
|
|
|
|
|
Hey all:
Can anybody give me ideas how can I lock the particular cell of the datagrids. I used Readonly properties of Datagrids, that makes whole datagrids uneditable.
I want only some particular cells of grids to be uneditable.
Thanks many for your advance help.
-- modified at 11:51 Friday 6th July, 2007
|
|
|
|
|
you can try this code
first you must set your grid readonly property to false
Dim intI, intJ As Integer
With grid
For intI = 0 To .Rows.Count - 1
.Rows(intI).ReadOnly = True
if intI = x then
.Rows(intI).ReadOnly = False
For intJ = 0 To .Columns.Count - 1
if intJ = y then
.Columns(intJ).ReadOnly = False
end if
Next
End If
Next
End With
hope this can help to solve your problem
|
|
|
|
|
Hey:
I'm using VB.NET 2003. I didn't find Datagrid1.Rows.count and Datgrids1.Columns.Readonly and ... features.
Can you help me how can add those features to grids to run your code?
Thanks for your help in advance.
|
|
|
|
|
Assuming that your datagrid is bound to a dataset, you can simply use the readonly property of the dataset's columns instead of that of the entire datagrid:
<br />
MyDataSet.Tables("MyTableName").Columns("MyColumnName").ReadOnly = False 'or True<br />
MyDataGrid.DataSource = MyDataSet<br />
MyDataGrid.DataMember = "MyTableName"<br />
Good luck,
Johan
My advice is free, and you may get what you paid for.
|
|
|
|
|
Hey thanks a lot!
I also thought in similar way that you thought. I still got some weird problems. I'm not allow to make the whole column unediatable. I can make only some of the cells of the column.
I'd appreciate if you could give me an idea how I can make a praticular cell unediatable rather than by whole coulumn. I'm sorry for my unclear questions
last time.
Thanks many for your help in advance
|
|
|
|
|
As far as I know, I am afraid you will have to make a choice; by the same principle you can determine the row index and make the row read only. So either make the entire row, or else the entire column read only (or the other way around). I have never tried myself, but perhaps you could investigate the possibility to determine the selected cell and try to make only that cell read only.
Another thing you could try is to make all rows read only, then when a user selects a row, make only that row editable, and during the same event make all columns except the selected cell's column read only again. I have no idea though whether this would actually work...
Good luck with it,
Johan
My advice is free, and you may get what you paid for.
|
|
|
|
|
Hey Johan:
Thanks a lot for good advice. Unfortunately, I was unable make a particular row uneditable. Below is my code.
Public Function CreateData(ByVal row As Integer, ByVal col As Integer)<br />
<br />
<br />
dt = New DataTable("sublayers")<br />
<br />
Dim i, j, k As Integer<br />
' col is used for determing column headers.<br />
<br />
dt.Columns.Add(New DataColumn("Sublayer No", GetType(String)))<br />
dt.Columns.Add(New DataColumn("Material Set No", GetType(String)))<br />
dt.Columns.Add(New DataColumn("Thickness (m)", GetType(String)))<br />
<br />
<br />
dt.Columns(2).ReadOnly = True<br />
<br />
<br />
<br />
For i = 1 To row<br />
<br />
dr = dt.NewRow()<br />
<br />
For j = 0 To col - 1<br />
<br />
<br />
dr(j) = " "<br />
<br />
<br />
Next<br />
dt.Rows.Add(dr)<br />
Next i<br />
<br />
'creating a datase<br />
Dim ds As New DataSet<br />
ds = New DataSet<br />
<br />
<br />
<br />
ds.Tables.Add(dt)<br />
<br />
'adding the table to dataset <br />
DataGrid1.SetDataBinding(ds, "sublayers")
I'm using this function to dynamically create datagrids. I neber got options to make rows uneditable. Can you advise how shall do this.
Thanks a lot for your help.
|
|
|
|
|
Hi,
My apologies, I misinformed you. I just mistakenly assumed there would be, but you are right, there isn't any direct option to make a row readonly.
The next option that comes to mind (and I don't see any alternatives), if you really need to lock only certain cells, is to set the readonly property of the datagrid to true, and bind the data from the selected datarow to regular textboxes or some other input system. This will allow you to control the input more easily, and to simply enable or disable a textbox when certain criteria are met.
Hope it helps,
Johan
My advice is free, and you may get what you paid for.
|
|
|
|
|
Hey:
Thanks a lot: I appreciate your time and help. I think I should think of making custom Datagrid control to add readonly features for each cell. Do you have any ideas how shall I do that?
|
|
|
|
|
I am sorry, I have no experience whatsoever in custom control making...
However there are plenty of people who have made custom datagrids, and I am sure Google could help you out with this subject. I seem to remember even seeing a few articles right here on the Code Project website with examples, etc.
Good luck,
Johan
My advice is free, and you may get what you paid for.
|
|
|
|
|
Hey friend>
Thanks, I appreciate your time and efforts. Thank your vey much for your suggestions.
|
|
|
|
|
Hello,
[VS 2005]
I have developed some code that uses a nested for loop. This code works the way it is supposed to. However, for maintaining this code I think i have not developed it in a efficient manor.
The way that the code works is that I have a database table and I am looping through the records finding the matching incidentID that have been delivered, so an e-mail can be sent.
As I am new to programming I am looking for a better way to do the same job.
I am sure there is a better technique for doing this, using some advance features of visual studio.
I am not looking for anyone to write me any code, just to review and give me an idea of another better technique.
Private Sub IncidentPartsArrivedEmail()<br />
Dim incidentID As Integer = 0<br />
Dim parts As List(Of String)<br />
Dim sentIncident As New List(Of Integer)<br />
Dim sendEmail As Boolean = False<br />
Dim orderID As Integer = CInt(Me.cboOrders.Text)<br />
<br />
Try<br />
'Loop through finding all the incidents that are ready to be sent.<br />
For Each outerRow As dsAddComponetAndEquipment.OrderDetailsRow In Me.DsAddComponetAndEquipment.OrderDetails<br />
'check to ensure that all the orders are for the same order.<br />
If (orderID = outerRow.OrderID) Then<br />
If (outerRow.Status = "Delivered") Then<br />
incidentID = outerRow.IncidentID<br />
'Ensure that the incident is not going to be repeated again.<br />
If Not (sentIncident.Contains(incidentID)) Then<br />
parts = New List(Of String)<br />
'Add the incident to the array to check later that this incident has already been done.<br />
sentIncident.Add(incidentID)<br />
For Each innerRow As dsAddComponetAndEquipment.OrderDetailsRow In Me.DsAddComponetAndEquipment.OrderDetails<br />
'check to ensure that all the orders are for the same order<br />
If (orderID = innerRow.OrderID) Then<br />
'Only the incidents with the same incidentID <br />
If (innerRow.IncidentID = incidentID) Then<br />
If (innerRow.Status = "Delivered" AndAlso innerRow.EmailStatus = "Waiting") Then<br />
parts.Add(String.Format("{0} - {1}", innerRow.Manufacturer, innerRow.Model))<br />
sendEmail = True 'Everything ok so send the email<br />
Else<br />
sendEmail = False 'Not all parts have been delivered <br />
Exit For<br />
End If<br />
End If<br />
End If<br />
Next innerRow<br />
If (sendEmail) Then<br />
Me.SendPartsEmail(Me.EngineersEmail(incidentID), parts, Me.CurrentUsersEmail())<br />
Me.TA_OrderDetails_dsCodeRed1.UpdateEmailSent(incidentID, orderID)<br />
End If<br />
sendEmail = False 'Set the flag back to false again to start the new incident<br />
End If<br />
End If<br />
End If<br />
Next outerRow<br />
Catch ex As Exception<br />
MsgBox(ex.Message)<br />
End Try<br />
End Sub
|
|
|
|
|
Looks to me like you're iterating through a data set when you could write a stored proc or SQL that does those comparisons in the data layer.
Christian Graus - Microsoft MVP - C++
"I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )
|
|
|
|
|
Try using a DataView with RowFilter.
So something like
dim dv as DataView = Me.DsAddComponetAndEquipment.OrderDetails.DefaultView
dv.RowFilter = "columnname = 'somedata'"
Once you have set the rowFilter you will only see the datarowview that match that filter. You would need to set the rowfilter back to "" to get all rows again.
Hope that helps.
Ben
|
|
|
|
|
I am using Visual Basic to make a website and I want a user to be able to enter things in a Textbox and have that information put into access. I am using a Inset statement but it does not work. I am useing:
INSERT INTO Results
(Application_contact)
VALUES (AC.[text])
And it does not work does anyone have any ideas how i can have the textbox information put into a access?? PLEASE HELP!!
|
|
|
|