Jump to content
Xtreme .Net Talk

joe_pool_is

Avatar/Signature
  • Posts

    512
  • Joined

  • Last visited

Everything posted by joe_pool_is

  1. I have two procedures that work together. If a child node is selected on a TreeView control, the records for the parent are displayed and focus is given to the child record. If the parent node is selected, I simply want to display the records associated with the parent node. It worked ok (by displaying all of the data rows) until I tried to apply a RowFilter to the DefaultView. Now, the DataGridView contains 0 Rows (see line 576 below), and my app would sit there and loop until it reaches a stack overflow (because of the test condition on line 552 and the recursive call on line 554) if I tried to deply it now. Instead of getting rid of the loop condition, I'd like to figure out how to fix the DataGridView's DataSource problem, because my code does not seem to take the statement like it is supposed to. One example that I saw showed to use DataGridView's DataBind method afterward applying a DataSource (line 575 below), but I don't know how to "unbind" the DataGridView for the next time I need to display a different table. 535: private void DataGrid_FindRow(TreeNode node) 536: { 537: string colName = node.Parent.Tag.ToString(); 538: if (DataGridView1.Columns.Contains(colName) == false) 539: { 540: DataGrid_Show(node.Parent); 541: } 542: if (DataGridView1.Columns.Contains(colName) == true) 543: { // just in case there was an error 544: DataGridViewCell cell = null; 545: for (int i = 0; (i < DataGridView1.Rows.Count) && (cell == null); i++) 546: { 547: if (DataGridView1.Rows[i].Cells[colName].Value.ToString().Trim() == node.Text) 548: { 549: cell = DataGridView1.Rows[i].Cells[colName]; 550: } 551: } 552: if (cell == null) { 553: DataGrid_Show(node.Parent); 554: DataGrid_FindRow(node); 555: } else { 556: DataGridView1.CurrentCell = cell; 557: } 558: } 559: } 560: 561: private void DataGrid_Show(TreeNode node) 562: { 563: if (0 < DataGridView1.Columns.Count) 564: DataGridView1.Columns.Clear(); 565: if (0 < DataGridView1.Rows.Count) 566: DataGridView1.Rows.Clear(); 567: if (Global.CpAppDataSet.Tables.Contains(node.Parent.Tag.ToString()) == true) 568: { 569: DataTable dt = Global.CpAppDataSet.Tables[node.Parent.Tag.ToString()].Copy(); 570: m_title = string.Format("{0} LIKE '{1}'", node.Tag.ToString(), node.Text); 571: dt.DefaultView.RowFilter = m_title; 572: dt.AcceptChanges(); // dt: Columns.Count = 9; Rows.Count = 1589 573: if (dt.Columns.Contains(node.Tag.ToString()) == true) 574: { 575: DataGridView1.DataSource = dt.DefaultView; 576: DataGridView1.Refresh(); // DataGridView1: Columns.Count = 9; Rows.Count = 0 577: } 578: DataGridView1.AutoResizeColumns(DataGridViewAutoSizeColumnsMode.AllCells); 579: string output = string.Format("{0} - {1} Records returned", node.Tag.ToString(), DataGridView1.Rows.Count); 580: UpdateStatusBar(output); 581: } 582: } As an FYI: If I do *not* create the DataTable copy on line 569 or apply a RowFilter on 571, the code correctly selects the row entry that matches the entry in the TreeView - but it also shows all 1589 records, whereas I want to filter this to only show the 10-100 records associated with that record's parent node. I hope this makes sense to others, and I hope my code example isn't too long and is easy enough to understand.
  2. Hi there, Pros! I've stumbled into needing to be able to do something like this. Within our company, I have to deply an application that will include DLLs that I created. Your thread above is very closely related, but it does not give me enough information to know what to do. What are keywords that I could google for this? Is there a good site that steps through how to configure a runtime configuration? In VS2005 Pro, Intellisence does not pick up <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">. Is this a hidden field, or do I need to add a reference to my project in order to gain access to it? I really appreciate this forum!
  3. Did you ever find a solution for this? I have created an installer using VS2005, but I can't seem to find a way to launch my app afterwards. The Setup Project has something about PostBuildEvent, and I suppose this would be for launching my application. But, I can't seem to find anything on how to use it.
  4. Hi Pete, I came across this because I need to do something similar. The difference I have is that my application will be run on multiple Citrix servers, and ClickOnce Deployment does not seem to work with Citrix servers. I am curious to hear other solutions, though.
  5. I tried setting it to null, and I got Visual Studio's default icon there instead. After fooling around with it for a while, it looks like it shows the icon in whatever size the icon actually is. I had loaded a 32x32 icon, which displayed nicely on the form, but grew to its full size whenever I maximized it. I replaced that icon with a 16x16 icon, and it looks ok. I'll keep it! :) For the record: MDI forms are a lot of work! Expecially with activating the MainMenu items, creating delegates to handle click events, and finding out how/when to activate the Cut/Copy and Paste items on the toolbar.
  6. I'm tackling my first MDI project. I have my MDI child loading up fine in my MDI parent. The parent has an icon and I assigned the same icon to the child so that they match. Now, if I maximize my child, it fills the parent, but the main menu gets large and includes the icon of the child - only bigger. Whoops! Not what I wanted. How do I fix this? Does the child form need a special FormBorderStyle property? Currently, I have it set to Sizable.
  7. Could anyone give me some information on how to screen capture on a Pocket PC or Windows Mobile device using Visual Studio (i.e Managed Code)? I written code to do it in the past using eMbedded VC, but very little of this will port over to VS. I've got working code for C# WinForms, except that it uses SendKeys (see code below). Unfortunately, SendKeys is not a part of the Compact Framework. Here's the method I'm trying to make, if it helps: private Bitmap m_bmp; public Bitmap PrintScreen() { SendKeys.SendWait("%{PRTSC}%"); // SendKeys is not defined! IDataObject ido = Clipboard.GetDataObject(); if (ido.GetDataPresent(DataFormats.Bitmap) == true) { m_bmp = (Bitmap)ido.GetData(DataFormats.Bitmap); string filename = "Bitmap_" + DateTime.Now.ToFileTimeUtc().ToString() + ".bmp"; m_bmp.Save(filename, Imaging.ImageFormat.Bmp); } } I'm trying to create tutorials for my CE Apps, and it would sure be nice if I could write screen capturing calls in my code whenever key events happen. Is there an alternative to capturing the screen to the Clipboard besides SendKeys? Thanks for any help!
  8. If KKQQ is still following this: KKQQ: Did you ever find a replacement for SendKeys in the Compact Framework? I just ran into the same troubles over here. Hopefully, you found an answer to this within the last 3 years. :)
  9. Thanks Plausibly! Your hint provided enough insite for me to troubleshoot around enough to find a solution. Instead of the code I was using above, I'm using this instead: private bool SendMessage(string fcn) { string fcn = "[email="Failed_Coil_Notify@Aaon.com"]Failed_Coil_Notify@Aaon.com[/email]"; string subject = string.Format("SystemID {0} - {1}", m_systemId, m_coil.SerialNumber); string message = "This message is formatted for HTML only."; MailMessage email = new MailMessage(fcn, fcn, subject, message); string body = "<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.0 Transitional//EN\">"; body += "<HTML><HEAD><META http-equiv=Content-Type content=\"text/html; charset=iso-8859-1\">"; body += string.Format("</HEAD><BODY bgcolor={0}><DIV><FONT face=Arial size=2>", split.Panel1.BackColor.Name); string fmt = "<div><b>Coil {0}: {1} Approved Override For {2}</b><hr><table border=1>"; body += string.Format(fmt, m_coil.SerialNumber, m_dbase.LeadSuper.FullName, m_dbase.Employee.FullName); string body2 = string.Empty; foreach (ListViewItem i in ListView.Items) { if (i.ImageKey == "stop.ico") { body2 += string.Format("<tr><td>{0} Issue:</td><td><b><font color=red>{1}</font></b></td></tr>", i.SubItems[0].Text, i.SubItems[1].Text); } } body += body2; body += "</table><hr></div><div>End Of File</div></FONT></DIV></BODY></HTML>"; email.IsBodyHtml = true; email.Body = body; SmtpClient Client = new SmtpClient("172.16.8.200"); Client.Credentials = System.Net.CredentialCache.DefaultNetworkCredentials; try { Client.Send(email); return true; } catch (Exception err) { Console.WriteLine(err.Message); return false; } finally { email.Dispose(); } }
  10. I've got some code that is chopping my subject line on the messages I receive, and I do not know why. Our server is running Active Directory and SQL Server 2000 Enterprise. The email is sent, but all we see in the subject line is "S". More debugging information: We do not reply to these system messages very often, but whenever we do, the header information (From, Sender, Date, Subject) all looks like it is in Chinese! Here is what I am doing: private bool SendMessage(string fcn) { MailMessage email = new MailMessage(fcn, fcn); email.SubjectEncoding = Encoding.Unicode; email.BodyEncoding = Encoding.Unicode; email.Subject = string.Format("SystemID {0} - {1}", m_systemId, m_coil.SerialNumber); string fmt = "<html><body bgcolor={0}><div><h3>Coil {1}<br/><font color=\"red\">{2}</font> Approved Override For {3}</h3><hr><table border=1>"; string body1 = string.Format(fmt, split.Panel1.BackColor.Name, m_coil.SerialNumber, m_dbase.Supervisor.FullName, m_dbase.Employee.FullName); string body2 = string.Empty; foreach (ListViewItem i in ListView1.Items) { if (i.ImageKey == "stop.ico") { body2 += string.Format("<tr><td>{0} Issue:</td><td><b><font color=\"green\">{1}</font></b></td></tr>", i.SubItems[0].Text, i.SubItems[1].Text); } } if (0 < body2.Length) { string body3 = "</table><hr></div><div>End Of File</div></body></html>"; email.IsBodyHtml = true; email.Body = body1 + body2 + body3; SmtpClient Client = new SmtpClient("172.16.8.200"); try { Client.Send(email); } catch (Exception err) { Console.WriteLine(err.Message); } finally { email.Dispose(); } } } If someone can catch it, I would sure appreciate knowing what I'm doing wrong.
  11. Using VS 2005. I tried using the Auto Complete setting (set AutoCompleteMode to SuggestAppend, AutoCompleteSource to CustomSource, and provided an AutoCompleteCustomSource after collecting the data), but Auto Complete didn't seem to do anything. Looking up Auto Complete, MSDN told me that the maximum number of Auto Complete values depends on the OS (rather vague). I presumed I was over running the buffer and it crapped-out on me (technical term). The data _does_ come from a table, but it has been messaged for readability where I have added additional columns. I can't seem to find out how to databind something that also has manually added columns. Lots of examples! ...but not many that step outside of the realm of automation.
  12. I've got a ListBox on my form with lots of data in it (14000 entries). I have to put a search field on the form. As text is entered into the search field, I want the ListBox to remove entries that do not match. Sounds simple enough, but it is really taking a long time! I started running it before opening my web browser, and now (with typing this message, I'm about to go over and hit a breakpoint) it is at ... 12687 entries, and all I've entered is one character into my filtering TextBox. Why is my version taking so long? What can I do to speed it up? private void Filter(string value) { for (int i = ListView1.Items.Count - 1; -1 < i; i--) { if (ListView1.Items[i].SubItems[1].Text.StartsWith(value) == false) { ListView1.Items[i].Remove(); } } ListView1.Refresh(); }
  13. No, BackgroundWorkers suck. I spent half the day re-tooling my code to work with these BackgroundWorker controls. Whenever I went to test the code, I found that these creatures never tell the parent when they are finished, and the code can't run them again until they tell the parent they are. My code just sat there doing nothing! The object of using BackgroundWorker controls was so that some of the database pulling and lengthy text validation could be handled by the threads (I had one for the db and one of text validating). I never was able to enter the second character on my text because the validating thread never stopped checking the text! It never even entered my text validating routine. So I removed it and just left the database thread in there. Same thing. It never returned either. So, after testing and banging around trying to get this to work, I spent the next several hours undoing all the BackgroundWorker garbage. (we really need some sort of version control here at work, but ...)
  14. I've found a very through example on the BackgroundWorker Class on MSDN here, but I have a question that it does not address. I have at least three (3) different, time-consuming tasks that I'd like to use a BackgroundWorker object on: Two for database queries, and one for text validation. Can a single BackgroundWorker object be used for all three (3) of these tasks? Some of the tasks do, on occasion, call on the other tasks. The BackgroundWorker's DoWork method includes a sender object. Would the sender be the name of the function that I used to call the BackgroundWorker's RunWorkerAsync method? Alternately, I could drop a separate BackgroundWorker component on the form for each of my time-consuming tasks, but this may not be necessary.
  15. I don't know why I never thought of using Cookies before. That'd save a lot of headaches. Thanks for the idea, Nate!
  16. Probably. (as far as I know) Each page is its own creature, if that's what you mean. The only reason one page has any idea about the other is because upon successful cranking through the code, it calls Response.Redirect to the page in the root folder. I'm hosting on GoDaddy. I know they are not the best, and they won't offer any support with this type of problem. But, I'm stuck using them for now. The older Classic ASP forms held the Session objects in a global way. I could set the values in a form running in one folder and they would be visible in other folders. Any thoughts on how to recreate this without going back to Classic ASP? I realize redesigning the entire website so that each piece of it looks to a global web.config file would probably be great, but that would take time that isn't avaiable at the moment. We just want the contact form to start working again.
  17. I'm declaring some session variables on one form, that are in a subdirectory. They do not seem to be visible in the main directory whenever I redirect to them. Am I missing something? Session variables are not declared, are they? I'm trying to port over some old Classic ASP code to C#, and I am declaring them similar to before: Session["value1"] = txtValue1.Text; Whenever I get to my other form, however, Session["value1"] does not exist. What's "the way" to do this?
  18. That works pretty darned well! Why are all the examples showing me how to do this with a SqlDataAdapter and DataTable? If I were to use a SELECT statement in an SqlCommand object, could I pull the information from it? How would I, for example, get VAL2 from Column2? What if more than one record is returned?
  19. Well... I really don't know! I'm just following the examples I've found. I'll give your way a spin.
  20. I've got some code that works whenever I fill my SQL Server tables, but now that I am getting used to how to do this, my technique is starting to look like it does some unnecessary steps. I have found that before I can call a SqlDataAdapter's Update method after specifying an InsertCommand, I have to provide it with a Select statement and call the Fill method so that the Column Names are known whenever I try to populate fields for my InsertCommand. After I call the SqlDataAdapter's Fill method, I create a NewRow for the DataTable, and supply each Column Name with a Value. Next, I create a new SqlCommand and add Parameter values to it. After this, I assign this SqlCommand object to the SqlDataAdapter's InsertCommand and call the SqlDataAdapter's Update method. Am I doing too many steps? It seems unnecessary to populate the Select statement and call the Fill method on the SqlDataAdapter first. It also seems like a waste of time to create a NewRow for the DataTable. Like I said, this does work. Should I continue in this fashion, or is there a more streamlined technique? string select = string.Format("SELECT [Column1], [Column2], [Column3] " + "FROM Table2 WHERE ([Column2='{0}')", strValue2); string insert = "INSERT INTO Table2 ([Column1], [Column2], [Column3]) " + "VALUES (@VAL1, @VAL2, @VAL3)"; SqlCommand cmd = new SqlCommand(select, m_db); SqlDataAdapter da = new SqlDataAdapter(cmd); DataTable dt = new DataTable(); try { da.Fill(dt); DataRow dr = dt.NewRow(); dr["Column1"] = strValue1; dr["Column2"] = strValue2; dr["Column3"] = strValue3; cmd = new SqlCommand(insert, m_db); cmd.Parameters.Add("@VAL1", SqlDbType.VarChar, 20).Value = strValue1; cmd.Parameters.Add("@VAL2", SqlDbType.VarChar, 20).Value = strValue2; cmd.Parameters.Add("@VAL3", SqlDbType.VarChar, 20).Value = strValue3; da.InsertCommand = cmd; int nCount = da.Update(dt); if (nCount != 1) { Console.WriteLine(string.Format("{0} records were affected.", nCount); } } catch (SqlException e) { Console.WriteLine(e.Message); } finally { cmd.Dispose(); dt.Dispose(); da.Dispose(); }
  21. I had to look up how to use StreamWriter, but you're right! It was MUCH easier! My code is now simply: if (File.Exists(strPath) == true) { using (StreamWriter sw = File.AppendText(strPath)) { sw.Write(historyMsg); sw.WriteLine("<hr>"); } }Thank you! Again, I owe you a cup of coffee!
  22. I used to append a file using Classic ASP on my website. I finally migrated parts over to .NET, but I can't seem to find out how to append a file. I can still determine if the file exists using File.Exists, but I don't know how to fill it! if (File.Exists(strPath) == true) { FileStream fs = null; try { fs = File.Open(strPath, FileMode.Append); char[] data = historyMsg.ToCharArray(); byte[] bdat = new byte[2 * data.Length]; for (int i = 0; i < (2 * data.Length); i++) { // how do I fill this part??? } fs.Write(bdat, 0, bdat.Length); } catch (Exception err) { Response.Write("<b>Unable to append to log file: <font color=\"red\">" + err.Message + "</font></b><br/><br/>"); ok = false; } finally { if (fs != null) { fs.Close(); } }
  23. Looks like F5 ran it anyway. What do you know? Visual Studio shouldn't list it as one of the errors with a red 'X' in the Error List bar if it isn't really an error. Thanks Derek.
  24. I have a couple of spots in my HTML that use z-index. The HTML displays correctly in Internet Explorer, but will not compile when part of my Visual Studio 2005 website project. This line, for example: [size=1][color=#0000ff] <[/color][/size][color=#a31515]div[/color] [color=#ff0000]class[/color][color=#0000ff]="logo"[/color] [color=#ff0000]style[/color][color=#0000ff]="z-index:2;"><[/color][color=#a31515]img[/color] [color=#ff0000]alt[/color][color=#0000ff]=""[/color] [color=#ff0000]src[/color][color=#0000ff]="~logos/blue.gif"[/color] [color=#0000ff]/></[/color][color=#a31515]div[/color][size=1][color=#0000ff][size=2]>[/size] [/color][/size]Gives me this error: Is there a way to fix this?
  25. Thanks! That does a good job. PD raises another question: Does the tilde (~) map to the root directory or simply to one directory up?
×
×
  • Create New...