Jump to content
Xtreme .Net Talk

haroldjclements

Avatar/Signature
  • Posts

    47
  • Joined

  • Last visited

Everything posted by haroldjclements

  1. Hello All, If I have a MessageBox with an 'Ok' and a 'Cancel', how do I create a function (or method) for each of these buttons? e.g. If I press 'Ok' it will access the new form and if I press 'Cancel' it remains in the form from which the button was originally pressed. Any help will be very much appreciated. Thanks, Harold Clements
  2. Hello, I think this will be an easy question to answer for an experienced .NET programmer. Can you change the colour of the text in a textbox that disabled? I have a light grey background to the text box which makes the text very difficult to read. Any help will be very much appreciated, Harold Clements
  3. Thanks very much, Stustarz, but that�s not quite what I am trying to get at (or I have completely misunderstood). When you use the LabelEdit property you can double click the desired line in the listView and it will allow you to edit the label row data but not any of its subitems. I was wondering whether there is a way that you can edit these subitems without having to create a new form and getting the user to input the changes there. Thanks again, Harold Clements
  4. Does anyone know how you can edit the subitems of the listView in the same way as you can the items text labels (this first item in the row)? Setting the LabelEdit property to true only effect the main item labels of the row not any of the subitems. Thanking you in advance, Harold Clements
  5. That is brilliant, thanking you both so kindly. Harold Clements
  6. .ShowDialog Method Thanks for your replay PlausiblyDamp Sorry for asking but how does the .ShowDialog method work? Thanks again, Harold Clements
  7. Hello, I have a thread question that has been bugging me for some time. If you are in the middle of an event (button1_click) and you call another form to be initialised. How can you pause the button1 event, work with the new form, when finished with the new form, hide it and carry on with the rest of the button_1 event? What I am trying to do is have a form that collects items from a database. If the item number is not known then a search button can be pressed (button1) and a search form (new form) be displayed where the used can search for the item within the database. When they have found the item that they are looking for they close the search form and button1 uses a �get� method to retrieve the value that you user found in the previous form. Now I can get it to work except that it looks for the get method instantly. I want it to look for the �get� method after the search form has been close. Is there a way of pausing this thread until the search form is closed? This in advance, Harold Clements
  8. The whole method Sorry, yes the whole method looks like this: Thanks for you help, Harold. private void printBOM(System.Drawing.Printing.PrintPageEventArgs e) { Brush b = new SolidBrush(Color.get_Black()); Brush br = new SolidBrush(Color.get_LightGray()); Font f = new Font("Courier New", 9, FontStyle.Regular); String sql = "SELECT ComponentPart, ComponentID, ComponentDescription, ManufactureShortForm, " + //0-3 "ComponentShortForm, ManufacturePartNumber, ComponentQuantity, ComponentIdent, " + //4-7 "tblKitParts.EngineeringChangeNoteID " + //8 "FROM tblKitParts, tblComponent, tblManufacture, tblComponentType " + "WHERE MotherLevel = " + partNo + " " + "AND ComponentID = ComponentPart " + "AND ManufactureID = ManufactureCode " + "AND tblComponentType.ComponentTypeID = tblComponent.ComponentType "; try { int k = 0; //not used x = minX; //reset X position OleDbCommand oc = new OleDbCommand(sql, myConnection); myConnection.Open(); OleDbDataReader dr = oc.ExecuteReader(); while (dr.Read()) { k ++; //Different colour for each line printed if (k % 2 == 0) {br = new SolidBrush(Color.get_LightGray());} else {br = new SolidBrush (Color.get_WhiteSmoke());} x = minX; e.get_Graphics().FillRectangle(br, x, y, maxX, cr); //Print solid blocks e.get_Graphics().DrawString(System.Convert.ToString(dr.GetInt32(0)), f, b, x, y); x += 45; e.get_Graphics().DrawString(dr.GetString(4), f, b, x, y); x += 45; e.get_Graphics().DrawString(dr.GetString(2), f, b, x, y); x += 320; e.get_Graphics().DrawString(System.Convert.ToString(dr.GetInt32(6)), f, b, x, y); x += 45; e.get_Graphics().DrawString(dr.GetString(3), f, b, x, y); x += 45; if (dr.IsDBNull(5)) {e.get_Graphics().DrawString("", f, b, x, y);} else {e.get_Graphics().DrawString(dr.GetString(5), f, b, x, y);} x += 320; if (dr.IsDBNull(8)) {e.get_Graphics().DrawString("", f, b, x, y);} else e.get_Graphics().DrawString(getECNData(dr.GetInt32(8)), f, b, x, y); getAlternative(e, dr.GetInt32(0), partNo, br); x = minX; //Reset X Position e.get_Graphics().FillRectangle(br, x, y, maxX, cr); //Print blocks e.get_Graphics().DrawString("Locations:", f, b, x, y); x += 90; if (dr.IsDBNull(7)) {e.get_Graphics().DrawString("", f, b, x, y);} else {e.get_Graphics().DrawString(dr.GetString(7), new Font("Courier New", 9, FontStyle.Bold), b, x, y);} y += cr; //Next line if ((y+(cr*2)) >= maxY) { e.set_HasMorePages(true); y = minY; } else {e.set_HasMorePages(false);} } myConnection.Close(); } catch (Exception error) { MessageBox.Show (error.toString() + extraErrorInfo, "Exception Error:", MessageBoxButtons.OK, MessageBoxIcon.Error); } catch (System.InvalidOperationException error) { MessageBox.Show (error.toString() + extraErrorInfo, "InvalidOperationException Error:", MessageBoxButtons.OK, MessageBoxIcon.Error); } catch (System.Data.OleDb.OleDbException error) { MessageBox.Show (error.toString() + extraErrorInfo, "OleDbException Error:", MessageBoxButtons.OK, MessageBoxIcon.Error); } catch (System.NullReferenceException error) { MessageBox.Show (error.toString() + extraErrorInfo, "NullReferenceException Error:", MessageBoxButtons.OK, MessageBoxIcon.Error); } finally { x = minX; //Reset X. y += 8; //Move page down. e.get_Graphics().DrawLine(new System.Drawing.Pen(Color.get_Blue(), 1), //Blue line new System.Drawing.Point(x, y), new System.Drawing.Point(maxX, y)); e.get_Graphics().DrawString("*** End of Listing ***", new Font("Courier New", 9, FontStyle.Bold), new SolidBrush(Color.get_Black()), x, y+3); y = minY; x = minX; } }
  9. Simplified .Net Printing in C# This may help! http://www.codeproject.com/useritems/Printing.asp I can now print but can't get multiple pages! Thanks, Harold
  10. Hello, I am trying to print on multiple pages but I can not seem to be able to get it right. I have a while loop that is pulling info from a database (the results of an SQL search). I know where the bottom of the page is so I added this: (line > maxPage) { e.hasMorePages(true); line = 0; } else { e.hasMorePages(false); } However, I do not get a new page. It prints over the original. If anyone has any ideas I would be very grateful. Thanks, Harold Clements (Please note that I am using J# but I can translate answers in C# or VB.NET.)
  11. Ok found it: if (myDataReader.IsDBNull(5)){textBox3.set_Text("");} else {textBox3.set_Text(myDataReader.GetString(5));} Cheers, Harold Clements
  12. Hello, I know it�s been a long time since your post but I have come across the same problem again. How would you check to see if the item being dragged from the database is null? If I use the �myDataReader.GetString(x)� within an �if� statement then I still get the error, so presumably I need to test the object before the conversion. My question is how? Thanks in advance, Harold Clements
  13. Now can you get the data that resided at the index that has just been selected? Thanks again, Harold Clements
  14. Hello, I am using a listView object to hold three columns of data pulled out of a database. What I want is the used to be able to click a line and the index and column data be available to be used within the next part of my program. I know that the listBox object has a .get_SelectedIndex() method. However the listView does not have this method. If anyone has any ideas I will be very grateful. Thanks, Harold Clements
  15. Sorted it :D Rather then declare the columns and the headers together, I created a ColumnHeader object and then used the .set_Width() method. It works fine, so I am happy. Cheers everyone, Harold Clements
  16. Thanks EFileTahi-A for your response. I don�t suppose that anyone could translate this line into J#? listView.get_Columnsdoes not have a width method! Thanks in advance, Harold Clements
  17. Hello all, Does anyone know how to adjust the width of your columns when using a ListView object? listView1.get_Columns().Add("Description", -2, HorizontalAlignment.Left); For some reason I through that the �-2� dictated the column width. However if I adjust this (either way) it just makes the width smaller. Any ideas with be gratefully received. Harold Clements
  18. That is excellent, it works beautifully. Thanks everyone :D
  19. Is there a way of getting a column effect in a listBox? I am dragging three lots of data from a database and want to format in row within the listBox. Example: Harold Clements 26 Right Handed James Smith 31 Right Handed Tom Cooper 19 Left Handed Thanks in advance, Harold Clements
  20. Ok, this piece of code works fine for me. What I want to be able to do is add a value (obtained from the database) to each line of the comboBox so that if the data is saved only the �ID� is saved and not the string description. I am struggling with the .NET syntax as much as anything and using J# is even harder as the volume of resource�s are very limited. Thanks in advance, Harold Clements sql = "SELECT * FROM tblComponentType"; OleDbCommand oc = new OleDbCommand(sql, myConnection); myConnection.Open(); OleDbDataReader dr = oc.ExecuteReader(); while (dr.Read()) { comboBox1.get_Items().Add(dr.GetString(1) + " (" + dr.GetString(2) + ")"); } myConnection.Close();
  21. Thanks Thanks guys for all you answers their very much appreciated.
  22. Cheers, it's comboBox1.set_Test = "Select Name"; Now how do tell the comboBox the value that the name represents (the db's unique ID). Thanks again, Harold
  23. Hello This is a quite easy question I hope. I am programming in J# (apologise if this is not the correct forum, I am just seeing if anyone has an idea). I am trying to obtain to fields from a database and deposit them into a comboBox. I have my database setup and retrieving the data. My problem is how I get the data into the comboBox. An example of the data is the database is: NameID Name 1 Harold 2 Nick 3 Bob 4 James When a name is selected the NameID is passed to the next form to retrieve more into on the person. This is what I have so far. <CODE> sql = "SELECT * FROM tblPeople"; OleDbCommand oc = new OleDbCommand(sql, myConnection); myConnection.Open(); OleDbDataReader dr = oc.ExecuteReader(); while (dr.Read()) { comboBox1.get_Items().Add(dr.GetString(1) + " (" + dr.GetString(2) + ")"); } myConnection.Close(); </CODE> This adds the names to the comboBox but gives me a blank box until I pull the box down. Really I would like something like �Select Name� and give it the index of 0. I understand that I have not added any index�s in, this is because I am unsure how to. Any help anyone could give me with this would be very much appreciated.
  24. Problem Solved With Thanks Thanks Robby and Joe, I have sorted the problem now, thanks alot for you help. Harold Clements
  25. I have a problem with writing to my database. The error that I receive is System.Data.OleDb.OleDbException: Operation must use an updateable query. at System.Data.OleDb.OleDbCommand.ExecuteCommandTextErrorHandling(Int32 hr) at System.Data.OleDb.OleDbCommand.ExecuteCommandTextForSingleResult(tagDBPARAMS dbParams, Object& executeResult) at System.Data.OleDb.OleDbCommand.ExecuteCommandText(Object& executeResult) at System.Data.OleDb.OleDbCommand.ExecuteCommand(CommandBehavior behavior, Object& executeResult) at System.Data.OleDb.OleDbCommand.ExecuteReaderInternal(CommandBehavior behavior, String method) at System.Data.OleDb.OleDbCommand.ExecuteNonQuery() I have the permissions on the database and directory that it is in set to �full control� but I still get this error. Does anyone have any ideas? Thanks in advance, Harold Clements
×
×
  • Create New...