Jump to content
Xtreme .Net Talk

archer_coal

Avatar/Signature
  • Posts

    96
  • Joined

  • Last visited

Everything posted by archer_coal

  1. it works It does work. I had multiple bindings my bad. Thanks a lot for your help Mutant
  2. Ok i set the datasource to nothing But somthing still isnt right. Listbox2.Datasource = Nothing Listbox2.Items.Clear() '<-- does nothing now Listbox2.Items.Add("test string")' <-- does not appear in the listbox
  3. "Error: Can't modify the Items collection when the DataSource property is set." I need some method of discarding the existing datasource before i can edit the listbox items.
  4. I'm having trouble with a databound listbox In the help files for vb.net it says to just bind the listbox again after new data has been Inserted. This produces Duplicates in the listbox. How do i clear the databox before i re-bind it? listbox1.Datasource.Clear() does nothing or so it seems. Simpley put, i want to empty the listbox then rebind it.
  5. re I also had to add Listbox1.ValueMember = Nothing to the delete Button to get rid of the error. Just in case anyone else was following this thread i thought i should post it. Thanks for your help everyone! It works fine now. Private Sub cmdDelete_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmdDelete.Click Dim testmsg As Integer Dim iVar As String iVar = ListBox2.SelectedItem(0) Label1.Text = iVar testmsg = MsgBox("Are you sure you want to remove this reminder?", 1, "Delete Reminder") If testmsg = 1 Then Dim myConnection As New OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\data\20304aa1.mdb") myConnection.Open() Dim MyCommand As New OleDbCommand("DELETE * FROM reminders where id = " & iVar, myConnection) MyCommand.ExecuteNonQuery() myConnection.Close() MyCommand.Dispose() ListBox1.DataSource = Nothing ListBox2.DataSource = Nothing Listbox1.ValueMember = Nothing 'added Listbox1.ValueMember = Nothing 'added ListBox1.Items.Clear() ListBox2.Items.Clear() m_DataSet.Tables.Clear() 'add this here, this will complete the clearing of data so you can restore it in the load_listbox call load_listbox() Else MsgBox("Reminder has not been removed") End If End Sub
  6. re I think I must not be using the best method to achieve this. The comments made on this problem seem to make sense in theory but for my program do not :p here is the code im toying with Private m_DataAdapter As OleDbDataAdapter Private m_DataSet As New DataSet() Private Sub load_listbox() m_DataAdapter = New OleDbDataAdapter( _ "SELECT * FROM reminders ORDER BY id", _ "Provider=Microsoft.Jet.OLEDB.4.0;" & _ "Data Source=C:\data\20304aa1.mdb") ' Fill the DataSet. m_DataAdapter.Fill(m_DataSet) ListBox1.DataSource = m_DataSet.Tables(0) ListBox2.DataSource = m_DataSet.Tables(0) ListBox1.ValueMember = "reminder" ListBox2.ValueMember = "id" End Sub 'Then the routine for deleting the item from the listbox Private Sub cmdDelete_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmdDelete.Click Dim testmsg As Integer Dim iVar As String iVar = ListBox2.SelectedItem(0) Label1.Text = iVar testmsg = MsgBox("Are you sure you want to remove this reminder?", 1, "Delete Reminder") If testmsg = 1 Then Dim myConnection As New OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\data\20304aa1.mdb") myConnection.Open() Dim MyCommand As New OleDbCommand("DELETE * FROM reminders where id = " & iVar, myConnection) MyCommand.ExecuteNonQuery() myConnection.Close() MyCommand.Dispose() ListBox1.DataSource = Nothing ListBox2.DataSource = Nothing ListBox1.Items.Clear() ListBox2.Items.Clear() load_listbox() Else MsgBox("Reminder has not been removed") End If End Sub After Listbox1 and 2 are set to nothing and are cleared, the previous items in the listboxes are replaced with System.Data.DataRowView
  7. I have a listbox bound to an oledb data connection with command buttons for delete and add. When the user selects an item and clicks on delete, the record is deleted fine but i cant get the listbox to show the changes without error. If i reload the listbox and its binding, it shows the previous items as well as the reloaded data. If i refresh the listbox nothing happens. If i try to use somthing like Listbox1.item.clear I get an error telling me i cannot clear when the datasource is set. How do i update the listbox to show the changes made after delete?
  8. RE I thought of that but I'll be using an image for the background. Thanks for the input though.
  9. RE Understanding WHY its doing what its doing would be great! If the code is faulty then help with fixing it would be great too. thnx My appologizes if the initial thread was not clear on that.
  10. These are the things that drive me nuts. Want to join me for the ride? Great! Here's what you do. ( yes there is a question with this) Step 1. To a form add Panel1(set its borderstyle to FixedSingle) , 4 listboxes named lb1,lb2, lb3, lb4 and a button Step 2. Make the panel large enough to fit all 4 listboxes inside then place them inside the panel evenly spaced Step 3. Anchor the listboxes as follows: lb1 (Top,Left) lb2( Top, Right) lb3 (Bottom, Left) lb4 (Bottom, Right) Step 4. Make your form considerably larger than the panel Step 5. Add the following code to the button's click event Panel1.Height = Me.Height / 2 Panel1.Width = Me.Width / 2 lb1.Height = (Panel1.Height / 2) lb2.Height = (Panel1.Height / 2) lb3.Height = (Panel1.Height / 2) lb4.Height = (Panel1.Height / 2) lb1.Items.Add(lb1.Height) lb1.Items.Add(lb1.Width) lb1.Items.Add(Panel1.Height) lb1.Items.Add(Panel1.Width) lb2.Items.Add(lb2.Height) lb2.Items.Add(lb2.Width) lb3.Items.Add(lb3.Height) lb3.Items.Add(lb3.Width) lb4.Items.Add(lb4.Height) lb4.Items.Add(lb4.Width) lb1.Width = (Panel1.Width / 2) lb2.Width = (Panel1.Width / 2) lb3.Width = (Panel1.Width / 2) lb4.Width = (Panel1.Width / 2) Panel1.Refresh() Step 6. Scratch your head and wonder why the only listbox behaving correctly is lb1. The others seem to drift off into the seams of the panel even though they are anchord and should not. Anyone have an idea why this happens or did I take the short bus to school? I'm assuming the anchor fires before the button click and therefore the x,y Drawing points of the listboxes are etched in stone before the boxes are resized/redrawn? It should be a simple task to keep controls uniform in the event of resizing a form! :confused: :mad:
  11. RE you could try a listbox binding to a listbox is tricky tho with the INSERT, UPDATE, DELETE routines
  12. re thanks about the sign :) Im glad it worked out but yea i wish we could have learned what the trouble was.
  13. re Thanks that worked nicely! :)
  14. re Works rather nicely Thanks!
  15. RE datagrid This is all ive found thus far on that subject add Imports System.Windows.Forms.DataGridTextBox 'create you custom colums and tablestyles and add Dim theCol As DataGridTextBoxColumn theCol.TextBox.Multiline = True Hope this helps
  16. RE try this for your form move changing Form2 to whatever your child form is of course :) Public i as integer Private Sub Form2_Move(ByVal sender As Object, ByVal e As System.EventArgs) Handles MyBase.Move i += 1 Me.Text = i & " Number of times moved" Me.Refresh() End Sub The caption at the top should change each time you move it and tell you how many times its been moved. If it dosnt then is it possible you are overriding the onPaint in some way?
  17. I have a listview with 2 columns column1 is Item column2 is subitem there are only 1 subitem per item i was wondering if there was a way to get the subitem text value from column2 when double clicking Item in column 1 here is what i tried with no luck Private Sub ListView1_DoubleClick(ByVal sender As Object, ByVal e As System.EventArgs) Handles ListView1.DoubleClick Dim i as integer Dim str as String str = ListView1.SelectedItems(i).SubItems(i).Text lblStr.Text = str End Sub The above code retrieves the text in the Items column for some reason and not the Subitem any help?
  18. Interesting hiccup I noticed that when using the above sample and a Colums collection that when you call Listview1.Clear ( then reload the listbox) nothing appears in the list I soon realized that i was clearing the column name with Listbox1.Clear and changed it to Listbox1.Items.Clear Just a note in case you were thinking of using columns
  19. re XML I found a nice XML class you can add to your project by Stan Shultes of vbexpert.com It's pretty simple to use and it comes with instructions, resoning, and an INI converter. I've uploaded it [HERE] Read the Readme.txt and the listings.rtf and everything should be pretty easy from there.
  20. RE I think ill try that, anyone fakin the DIR gets what they deserve i say LOL
  21. anyone know of an easy way to detect if the .NET framework is installed? I know that most setup and deployment projects do this automatically but is there a way to do it programatically? Id rather not skim through the registry if thats possible but if thats what it takes then so be it.
  22. RE I thought of that and figured the dataset and dataadapter Connection String would be invalid. I may be wrong but i think the default connection strings used in dataadapters do not support variables such as AppPath (when using the wizard) That would mean rebuilding my datagrid columstyles programatically and id really rather not do that.
  23. Is there a way to Force the creation of a folder on a user's sytem? I have an application using oledbdataadapter's etc and they're all pointing to C:\DATA\DATABASE.MDB but custom folder properties uses at best TARGETDIR which allows the user to select the folder. Other possible selections have no editable property that i can see. I just want to make a folder called C:\Data and have the files stored there. I dunno why it's so hard to do that LOL :D Thanks anyone who has any feedback.
  24. RE PM me with your EMAIL address and ill email the source to you.
  25. re networking I found a nice NETSTAT example for networking in VB.NET that may shed some light on the subject for you. http://www.codeproject.com/vb/net/netstat.asp and here is a console http proxy source i found as well http://www.planet-source-code.com/vb/scripts/ShowCode.asp?txtCodeId=1145&lngWId=10 Hope they help
×
×
  • Create New...