Jump to content
Xtreme .Net Talk

Diesel

Avatar/Signature
  • Posts

    682
  • Joined

  • Last visited

Everything posted by Diesel

  1. FindString will not work because you need to search for the value? If you convert the value to a string, how is it that find string will not work? Either way, you could create a mapping of the first combobox value to the second... Im assuming that there is a one to many relationship between combo2 and combo1, as in there could be multiple items you can select in combo1 that will result in the same item being selected in combo2. If it's a one to one relationship then this whole thread is crap and you would have just ordered each list so that when you select item 5 in combo1, item5 is selected in combo2. If there is a one to many from combo1 to combo2, then I don't know how you will figure out which item is to be selected in combo2 when an item is selected in combo1. Anyway, just create an array and populate the array with the index of the item to select in combo2 when that array index matches the index of the item selected in combo1. int[] itemMap = new int[this.comboBox1.Items.Count]; itemMap[0] = 5; itemMap[1] = 2; itemMap[2] = 3; There might be a better way, but hell if I know.
  2. Dim threads As New ArrayList() Private Sub RefreshData Dim ThrData As New Thread(AddressOf LoadMemos) threads.Add(ThrData) ThrData.Start() End Sub Protected Overloads Overrides Sub Dispose(ByVal disposing As Boolean) If disposing Then If Not (components Is Nothing) Then components.Dispose() End If End If For Each o As Object In threads If Not o Is Nothing Then Dim th As Thread = CType(o, Thread) If th.ThreadState = ThreadState.Background Or th.ThreadState = ThreadState.Running Then th.Abort() th = Nothing End If End If Next MyBase.Dispose(disposing) End Sub Not sure if it's the best way to do it, but it works
  3. dr = ddlDC.DataSource.Tables(0).NewRow this sets dr as a typed datarow...a class that is dynamically created when you filled the dataset Changing the declaration should fix the problem. Dim dr As ddlDC.DataSource.Tables(0).NewRow
  4. Anyone read any great 2.0 books yet? Anyone read the asp.net book by Dino?
  5. Opacity also affects the controls on the form, so that wouldn't work. Well, the only thing I can think of is going to the source. When you set the background transparent, .net calls a painttransparentbackground function...instead of checking to see if the background is transparent, you could override OnPaintBackground and just paint it transparent. It gets rid of a few if-then statements. Unfortunately, I haven't been able to get it to work...but here's the code if your interested... If you comment out the 4th to last line graphics1.FillRectangle(SystemBrushes.Control, pevent.ClipRectangle) You'll notice it gives the same effect as a transparent background...but the form still picks up mouse input. The parent control is always null. The actual painttransparentbackground function uses control1 = me.parentInternal, but this property is not accessible from the form class. Imports System.Drawing.Drawing2D Imports System.Runtime.InteropServices Public Class Form1 Inherits System.Windows.Forms.Form <DllImport("user32.dll", CharSet:=CharSet.Auto, ExactSpelling:=True)> _ Public Shared Function MapWindowPoints(ByVal hWndFrom As HandleRef, ByVal hWndTo As HandleRef, ByVal pt As Point, ByVal cPoints As Integer) As Integer End Function #Windows Designer Code Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load Me.TopMost = True End Sub Protected Overrides Sub OnPaintBackground(ByVal pevent As System.Windows.Forms.PaintEventArgs) Dim graphics1 As Graphics = pevent.Graphics Dim control1 As Control = Me.Parent If (Not control1 Is Nothing) Then Dim num1 As Integer = 0 Dim point1 As New Point(0, 0) MapWindowPoints(New HandleRef(Me, Me.Handle), New HandleRef(control1, control1.Handle), point1, 1) pevent.ClipRectangle.Offset(point1.X, point1.Y) Dim args1 As New PaintEventArgs(graphics1, pevent.ClipRectangle) Dim state1 As GraphicsState = graphics1.Save Try graphics1.TranslateTransform(CType(-point1.X, Single), CType(-point1.Y, Single)) Me.InvokePaintBackground(control1, args1) graphics1.Restore(state1) state1 = graphics1.Save graphics1.TranslateTransform(CType(-point1.X, Single), CType(-point1.Y, Single)) Me.InvokePaint(control1, args1) Return Finally graphics1.Restore(state1) End Try End If graphics1.FillRectangle(SystemBrushes.Control, pevent.ClipRectangle) graphics1.Dispose() End Sub End Class I don't know if the performance increase is worth the effort.
  6. MailMessage m = new MailMessage(); m.To = email.Value; m.From = "jack@abc.com"; m.Subject = "2005 Pictures"; m.BodyFormat = MailFormat.Html; m.Body = "Here are the pictures you requested. The pictures you requested to be printed are on their way"; //Add File Attachments string[] pics = files.Value.Split(';'); foreach (string s in pics) { if (s != string.Empty) { string localPath = s.Replace("http://localhost/CatalogView", ""); m.Attachments.Add(new MailAttachment(Server.MapPath(string.Empty) + localPath, MailEncoding.UUEncode)); } } SmtpMail.SmtpServer = "10.5.5.5"; SmtpMail.Send(m); The attachments are sent in the message, not as attachments... I've searched the web a little, but was wondering if anyone has had this problem b4?
  7. So, you want to make the datagrid raws bigger if there is not enough to fill the datagrid window? if ( (this.dataGrid1.PreferredRowHeight * this.dataGrid1.VisibleRowCount) < this.dataGrid1.Height - 60) { this.dataGrid1.PreferredRowHeight = (this.dataGrid1.Height-60) / this.dataGrid1.VisibleRowCount; } 60 would be the standard blue header and column headers on the datagrid. I don't know how to retrieve those values. For vb, just change 'this' to 'me' and '{' to 'then' and '}' to 'end if' and get rid of the ;
  8. What you are trying to accomplish could probably be done in a better way. Did you copy the code, because the declaration of your variable is spelled strFieldss, whereas your using strFields. Dim strFieldss As String Where is (the variable) i coming from? Also, you should compare strFields to string.Empty instead of "" Also, this is called boxing... strFields = i and is considered a performance no-no. Also, the Split function takes a char array, so naming the parameter strDelimiter is misleading. For Each strFields In oSR.ReadLine().Split(strdelimeter) Also, Im sure you know, but your code only reads one line from the file... if you want to read the whole file, just surround the for next loop with while (oSR.Read()) end while Now, to the actual problem... The extra column it's adding, Im assuming is a number? The only way I can see that an extra column would be added if there were spaces after the last word on the first line. The [easiest], and Im assuming you want the easiest solution is this For Each strFields In oSR.ReadLine().Trim().Split(strDelimiter)
  9. Your welcome.
  10. AutoScroll should work. Play around with the AutoScrollMinSize property of the form.
  11. What the ****! **** VB.NET. It's all the ****ing Same! Learn to program you dumbass! If you can't use my code, your ****ing useless. This is the last time I help a retard! I practically wiped your *** for you! What else can I do?
  12. As for dealing, just have a variable keep track of what position in the deck (array) you are at.
  13. An actual commercially used deck shuffling function: private Card[] cards; #region Enumerations /// <summary> /// Defines a card suit /// </summary> public enum Suit: int { /// <summary> /// Clubs suit /// </summary> Clubs = 0, /// <summary> /// Diamonds suit /// </summary> Diamonds, /// <summary> /// Hearts suit /// </summary> Hearts, /// <summary> /// Spades suit /// </summary> Spades } /// <summary> /// Defines a card rank /// </summary> public enum Rank: int { /// <summary> /// Ace card /// </summary> Ace = 0, /// <summary> /// Two card /// </summary> Two = 1, /// <summary> /// Three card /// </summary> Three, /// <summary> /// Four card /// </summary> Four, /// <summary> /// Five card /// </summary> Five, /// <summary> /// Six card /// </summary> Six, /// <summary> /// Seven card /// </summary> Seven, /// <summary> /// Eight card /// </summary> Eight, /// <summary> /// Nine card /// </summary> Nine, /// <summary> /// Ten card /// </summary> Ten, /// <summary> /// Jack card /// </summary> Jack, /// <summary> /// Queen card /// </summary> Queen, /// <summary> /// King card /// </summary> King } /// <summary> /// Randomizes the elements in the array /// </summary> public void Shuffle(int seed) { //first put cards back in order int current =0; for( int j=0; j < this.cards.Length/52; ++j ) { for ( int y = 0; y < 4; ++y) { for ( int x = 0; x < 13; ++x) { cards[current++] = new Card( (Suit)y, (Rank)x); } //end for suit } //end for rank } //end for numberDecks //then shuffle from seed System.Random random = new Random(seed); // temp variable need to do the swaping int temp = 0; Card card; // for every card in the deck switch it with another for(int i = 0; i < cards.Length; ++i) { temp = random.Next(0,cards.Length); card = (Card)cards[temp]; cards[temp] = cards[i]; cards[i] = card; } //end for this.currentCard = -1; } Card class should be something like: /// <remarks> /// Represents a card /// </remarks> public class Card { #region Private Variables private Suit suit; private Rank rank; // contains the value of the card in bits // the first 2 bit contain value of the suit // the last 4 contain the rank. // IE 2 of Hearts is // 10 0010 = 18 private int cardValue; #endregion #region ctor /// <summary> /// Initializes a new instance of the Card Class. /// </summary> public Card(Suit cardSuit, Rank cardRank) { this.suit = cardSuit; this.rank = cardRank; cardValue = (int)suit; cardValue <<= 4; cardValue += (int)cardRank; } #endregion
  14. Browsable is a design attribute. I think you solved the problem for yourself. I don't know how you are displaying the information, but how about checking the relation of the user to the record and then imposing a readonly status on that field if appropriate.
  15. Are the labels public? Barring any cool design trick, the easiest way would be to expose the font of the control as a property and impose constraints there. Will each label have a unique font? All the same? public Font HeaderFont { get { return this.headerFont; } set { if (value.Size >= 8.25 && value.Size <= 10) { this.headerFont = value; } } }
  16. Let's say I have an xml file...it doesn't make a difference, but let's say the format is <project> <file><name>assemblyInfo.cs</name></file> <file><name>Form1.cs</name></file> <file><name>SuperCoolApp.cs</name></file> <file><name>Form1.cs.resx</name></file> <file><path>Resources</path><name>Logo.gif</name></file> </project> It just lists the files in the project. Now, In Visual Studio, when you add/delete a file from the project I want to update this Xml file. Im thinking I maybe able to accomplish this through a VS project template. Anyone done this?
  17. You have not specified the connection used for the command... Your constructor is most likely: Dim Dim command as new OleDbCommand(connectionString) Either use: Dim command as new OleDbCommand(connectionString, connection) or if a connection is not available at that point, set it later... command.Connection = connection If you don't know how to create a connection, look up OleDbConnection in msdn
  18. Anyone entering the Messenger Activity Contest? http://www.worldsbestapp.com/ They're making a big deal out of it.
  19. lvItem.SubItems.Add(reader("ClassDate").ToString())
  20. You are reloading the listview on the wrong event. If you reload the listview on the selectedindexchanged event, everytime the user selects a new row the listview will be reloaded. If right now all you are doing is adding a record the database, you need to send an event to this form when a record is successfully added to the database. Take a look at my other post to add the event. Also, you might want to fix up your 'fetching' code... Get rid of the class variables...except for oledbcon Private Sub LoadClasses() Me.ListView1.Items.Clear() Dim command As OleDbCommand Dim reader As OleDbDataReader Try oledbcon.Open() command = New OleDbCommand("SELECT * FROM class", oledbcon) reader = command.ExecuteReader(CommandBehavior.CloseConnection) While reader.Read() Dim lvItem As New ListViewItem(reader("ClassID").ToString()) lvItem.SubItems.Add(reader("ClassDescription")) lvItem.SubItems.Add(reader("ClassDate")) Me.ListView1.Items.Add(lvItem) End While Catch ex As OleDbException MessageBox.Show(ex.Message) End Try reader.Close() End Sub #End Region #Region " .... load event .... " Private Sub frmClass_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load Me.LoadClasses() End Sub #End Region Call LoadClasses in Form_Load and get rid of the SelectedIndexChanged Event. And Again, add an event to the form that adds records to the database, handle the event in the parent form. Have the parent form call LoadClasses to refresh the listview.
  21. The listview should be populated by it's own container. And no matter what, if you reload the listview after a new record is added or deleted, it will show the new/deleted record!
  22. If you are doing this to learn, why not read a book.
  23. You have to repopulate the listview...or just add the new item to the end (if it's not sorted or you don't care) Put the code you use to populate it in a seperate function and call it when it needs to be refreshed, but add listview.Items.Clear() as the first line in the new function. And call that function at load
  24. Save the id somewhere. Either in a list that corresponds to the order of items in the listview or wrap the data from the database in a object and use those objects to populate the listview. When a line is selected from the listview, find the object and you have the id. Is there a parent mdi form? If so, the way that I pass data from child to child is to raise an event in the child, sending the appropriate data to the parent. The parent handles the event and passes the data wherever. Im not sure if this is the recommended way (if there is one), but it's clean. namespace XtremeDotNet { #region Using Directives using System; using System.Drawing; using System.ComponentModel; using System.Windows.Forms; #endregion #region Delegates public delegate void MyEventHandler(MyEventArgs e); #endregion public class MyForm: System.Windows.Forms.Form { public event MyEventHandler myEvent; //Constructor //Form Designer Code #region Event Handlers protected void OnMyEvent(MyEventArgs e) { if (this.myEvent != null) this.myEvent(e); } #endregion private void MyForm_SomeButtonClicked(object sender, EventArgs e) { this.OnMyEvent(new MyEventArgs("hi")); } } public class MyEventArgs: EventArgs { using System; private string text; public string Text { get { return this.text; } set { this.text = value; } } public MyEventArgs(string text) { this.text = text; } } } something like that
  25. Postfixing Attribute to a class is not a good idea unless it inherits from System.Attribute. Do you have access to the classes you want to set readonly? If so, then reflection is not needed. Also if you know the type of class, reflection is not needed. Are the fields in these classes static? using System; namespace ReflectionTest { /// <summary> /// Summary description for SuperString. /// </summary> public class SuperString { private string text; private bool readOnly; public string Text { get { return this.text; } set { if (!(this.readOnly)) { this.text = value; } } } public bool ReadOnly { get { return this.readOnly; } set { this.readOnly = true; } } public SuperString(string text) { this.text = text; } } }
×
×
  • Create New...