Jump to content
Xtreme .Net Talk

pelikan

Avatar/Signature
  • Posts

    90
  • Joined

  • Last visited

Everything posted by pelikan

  1. you'll probably have to subclass the DataGrid control and override the protected ProcessKeyMessage method. If the WM_KEYDOWN is a [Return] handle it as you wish. return True if you handle it, otherwise return base.ProcessKeyEventArgs(Message m);
  2. a nice, modern, light approach is: XML - guess what you get with .NET ? tons of built in XML support. define your schema read and write your XML data into DataSets expose the data as exported XML via HTTP Web Service your clients will understand your data as long as they can get a copy of the schema.
  3. .value??? no such animal but all problems except you know what have a solution Public Function SumBits(ByVal ba As BitArray) As Integer Dim accum As Double = 0.0 Dim i As Integer For i = 0 To ba.Count - 1 If ba(i) Then accum += 2 ^ i End If Next Return CInt(accum) End Function
  4. if what you did, didn't work completely uninstalling and reinstalling seems next. VS uses some gaziilion registry keys - it's all com
  5. XP probably rolled back over some of VS's registry keys - suggest you reinstall the product.
  6. I shudder in horror at the sight of that code. try using the binding architecture of Net Windows instead.
  7. Just grokked your flok. (by the way, did mean OOOM ) Sounds like you want a simple lookup combo fella. Proof-of-concept scenario: Table1 ("Item", "Value") Table2 ("Blah", Blah1", Blah2", "Item") - "Item" is foreign key to Table1("Item") UI: ComboBox .DataSource = ds.Tables("Table1") .DisplayMember = "Value" .ValueMember = "Item" DataGrid .DataSource = ds .DataMember = "Table2" finally: cboTable1.DataBindings.Add("SelectedValue", ds, "Table2.Item") test it: change the selected row in the datagrid, the combo stays in sync because SelectedValue is 'simple bound' to Table2.Item get the CurrencyManager: myCurrencyManager = CType(me.BindingContext(ds.Tables("Table2")), CurrencyManager) change the SelectedValue via myCurrencyManager.Position - voila, SelectedIndex in combo changes.
  8. repeat after me - OOOOM.... your frustration is baseless. With the Managed Combo control you actually get a great deal more flexibility than you had in the dark ages of VB6 or C++. Then, you had an ItemValue field for each list element (a DWORD) - it's still there in the underlying Windows control, but there are better, type safe ways to accomplish the kinds of things this field was intended for (back in the days when windows were written with giant switch statements). It took me a while to get used to incredible binding possibilities of managed controls, so I sympathize with your confusion (except for the "hard coding" bit - never a good idea) Here's what you have to work with: DataSource DisplayMember ValueMember SelectedValue Think about what happens when you set the first 3 properties to a table that looks like this: itemkey, displayValue Then bind the SelectedValue property to something with: cbo.DataBindings.Add("SelectedValue", SomeOtherTable, "itemkey") As to the hard coding bit, if all you want is a rigid (itemValue:itemString), remember that combobox items are objects - not strings. you can define a Pair object with two fields (itemData, itemString) + overridden ToString method which simply returns the itemString. :eek:
  9. this is what the data adapter essentially does Dim size_est As Integer Dim dMatrix As New ArrayList( size_est ) 'set up command and connection 'get your fire hose data cursor Dim rdr As OleDbDataReader = cmd.ExecuteReader() ' Dim oRow( rdr.FieldCount - 1 ) As Object While rdr.Read rdr.GetValues( oRow ) dMatrix.Add( oRow ) End While rdr.Close() 'use the data 'do something with dMatrix(i)(j) actually the above has a major flaw (can you see it?) - the object reference oRow remains the same thru the iteration - so all elements of the ArrayList contain a reference to the same - object to correct this you have to use the Array static constructor: Dim size_est As Integer Dim dMatrix As New ArrayList( size_est ) 'set up command and connection 'get your fire hose data cursor Dim rdr As OleDbDataReader = cmd.ExecuteReader() ' Dim colCount As Integer = rdr.FieldCount Dim oRow() As Object While rdr.Read 'make a new row using static method 'note that the array is (0 .. colCount - 1) unlike VB's odd syntax oRow = Array.CreateInstance( GetType(Object), colCount ) rdr.GetValues( oRow ) dMatrix.Add( oRow ) End While rdr.Close() 'use the data 'do something with dMatrix(i)(j)
  10. your modal form shouldn't be mucking around with DataSets - it should have public property, the filter string for your DataView which gets built by the UI.
  11. you can create an 'expression' based column to calculate aggregate functions. if a relation is involved, something like: ds.Tables["Orders"].Columns.Add("OrderTotal", typeof(Int32), "Sum(Child("OrderToOrderDetails").Quantity)");
  12. While Plausibly's link show's quick hack - you might find this (using inheritance) to be a cooler, more flexible method http://www.msdn.microsoft.com/library/default.asp?url=/library/en-us/dnwinforms/html/SACP_WinForms.asp
  13. try this function public static string foo(string s, int n) { int ix, w, m; ix = s.IndexOf('0'); if (ix != -1) { w = s.Length - ix; StringBuilder result = new StringBuilder(s, 0, ix, 100); m = Convert.ToInt32(s.Substring(ix)) + n; string sNum = m.ToString(); if (sNum.Length < w) w -= sNum.Length; else w = 1; result.Append(sNum.PadLeft(sNum.Length + w, '0')); return result.ToString(); } throw new ArgumentException("Invalid String"); }
  14. You said 'ensure 2 digits long' works on my machine. You need to retake math 101 and learn what a number is, binary numbers don't have padded 0's. if you just want a '0' before your number: String.Format("{0:'0'0}", lowest); works on my machine 900 -> 0900, 91 -> 091, 9 -> 09 etc.
  15. you're being too gentle Arch4ngel!
  16. the error message says it all: you can't have 2 key definitions in the db with the same name, give them different names. (here - ElementID is ambiguous)
  17. my error. # is a placeholder for nothing try: lowest.ToString("00"); or : String.Format("{0:"00"}, lowest); (don't have any clue what a 'Stringer' is). an integer is an object with overloaded ToString methods.
  18. CollectionBase is used to create "strongly typed" collections - what you are doing is nonsense - just use an ArrayList if you want to throw any old thing in there.
  19. lowest.ToString("#0"); or String.Format("{0:#0}", lowest); ---check out composite formatting & custom format patterns
  20. the article ref doesn't look too bad, but the whole conception seems misguided. You want printed copy of the data in a view or table? You also have unlimited funds to refill color ink for your printer? Fine, but use XSLT and transform the data to whatever your needs dictate (XSL-FO for high grade report quality)
  21. Polymorphism - get used to it, you're not in Kansas anymore and VB.Net isn't VB 6. An XmlElement is-a XmlNode
  22. Please don't do this crazy thing. TreeNodes know nothing about keys! Think of all it's trusting children TreeNodes awaiting the dreaded Garbage Collecter when you dispatch their mama!
  23. seems to me you'd have to draw your print doc to a metafile and put that on the clipboard. - not sure how this is done in .net
  24. Also note - ds is uninitialized ie Null object reference.
  25. Your last looks a little odd. Heres how I would do it in VB 'Build Tree 'Make sure you have no "cyclic" references in Chapter Table! Private Sub BuildTree() Dim BookNode As TreeNode For Each drBook As DataRow In tbCookBooks.Rows BookNode = New TreeNode BookNode.Text = drBook("BookName").ToString Me.trvTreeView.Nodes.Add(BookNode) For Each drChapter As DataRow In drBook.GetChildRows("ChapterToBookRelations") '**** your syntax looks really odd here '- check for DB Null value If drChapter.IsNull("ParentID") Then 'top level chapter found BookNode.Nodes.Add( CreateChapter(drChapter) ) End If Next Next End Sub 'Using a function here to return a treenode seems clearer 'why were you passing references ByVal ? Private Function CreateChapter(row As DataRow) As TreeNode Dim ChildNode As New TreeNode ChildNode.Text = row("ChapterName").ToString 'check this row for sub chapters For Each subRow As DataRow In row.GetChildRows("ChapterToChapterRelations") ChildNode.Nodes.Add( CreateChapter(subRow, ChildNode)) Next Return ChildNode End Sub
×
×
  • Create New...