
RobEmDee
Avatar/Signature-
Posts
132 -
Joined
-
Last visited
Content Type
Profiles
Forums
Blogs
Events
Articles
Resources
Downloads
Gallery
Everything posted by RobEmDee
-
How can Reflection be used to access the Property of an object through it's string representation? Similar to the functionality of the ValueMember, DisplayMember Properties for the ListControl object.
-
Simon: You can get a reference to both the HScrollBar and VScrollBar of the DataGrid through its Controls collection. Once you get the references, you can manipulate them as you would any other Control on the Form.
-
APaule: Thanks for taking a look. I realize now that I am only experiencing the behavior I described with ListBoxes that I have taken ownership of the drawing (DrawMode = OwnerDrawVariable).
-
I am using the IndexFromPoint() method of the ListBox inside of the MouseMove event handler to identify which ListBox item a user's mouse is hovering over at any given point. This has worked well. The one annoyance I have found is that when the mouse is over empty ListBox space below the last ListBox item, IndexFromPoint() returns the index of the last ListBox item even though technically the mouse is not over any items. Does anyone have a quick workaround for this? Thanks.
-
Nice catch Plausibly........ Roswell: RichTextBox.Lines already does what I described above.
-
marble: This is a really helpful article that opens the door to some great Control behavior. Thanks for digging it up and passing along the good info!
-
Roswell: This would be an easy way to get a string array of the lines in a RichTextBox without the overhead of handling the Key events /// <summary> /// Uses new line breaks to split RichTextBox text into a string array of lines. /// </summary> /// <param name="rtb">RichTextBox containing text to break.</param> /// <returns>Array of RichTextBox lines.</returns> private string[] SplitRichText(System.Windows.Forms.RichTextBox rtb) { return rtb.Text.Split(new char[]{char.Parse("\n")}); }
-
Alex: C# does not support parameterized properties. Check out Indexers .
-
The SelectAll() method of the TextBox will get the specific job done also.
-
lothos: You need to cast sender to its actual type. I believe you use CType() in VB.NET.
-
diya: This is one way I have used in the past to handle your requirement. Hope this helps. public ArrayList SelectedValues() { ArrayList selValues = new ArrayList(); DataRow row; for(int count = 0; count < this.listBox1.SelectedItems.Count; count++) { row = ((DataRowView) this.listBox1.SelectedItems[count]).Row; selValues.Add(row[this.listBox1.ValueMember]); row = null; } return selValues; }
-
argh! Never mind.....I found my problem. I guess its time to take a break! :o
-
I have a UserControl with a DataGrid and a UserControl with a ListBox both running inside of the same form. The ListBox is loaded with a fixed number of items when the form is instantiated. The number of items in the grid periodically changes throughout the life of the form. I use ListBox.IndexFromPont() in the MouseMove event of the ListBox to retrieve information about the objects in the ListBox items collection. It has worked quite well for some time. However, today the IndexFromPoint() method began returning indices starting at 19 (e.g item 1 = index 19, item 2 = index 20, item 3 = index 21, etc). The only kind of pattern or correlation I have been able to find is that when the number of items in the grid gets up around 50 or greater, this ListBox issue begins happening. If the grid only has a few items, this issue does not happen. Has anyone seen anything like this before!?
-
Check out the grids from ComponentOne
-
lidds: Below is a simplified example of an approach I have used before to accomplish a similar task. The gist of it is that you maintain a collection with the drawing information for different items to be drawn on your Control. You can then add and remove items to the collection to add and remove them from the Control. This approach can be significantly enhanced to meet your specific needs......I would suggest creating a custom PictureBox which encapsulates all of the functionality. Hope this helps. // Collection to hold current items to draw private ArrayList itemsToDraw = new ArrayList(); // Type to hold item drawing information private struct DrawingItem { public int DrawVal1; public int DrawVal2; public int DrawVal3; public int DrawVal4; public Color DrawColor; public DrawingItemType Type; public DrawingItem(int val1, int val2, int val3, int val4, Color color, DrawingItemType drawType) { this.DrawVal1 = val1; this.DrawVal2 = val2; this.DrawVal3 = val3; this.DrawVal4 = val4; this.DrawColor = color; this.Type = drawType; } } // Type to define drawing item private enum DrawingItemType { Line, Rectangle, Ellipse } // Add drawing item to collection private void AddItem(DrawingItem item) { this.itemsToDraw.Add(item); this.pictureBox1.Invalidate(); } // Remove drawing item from collection private void RemoveItem(DrawingItem item) { this.itemsToDraw.Remove(item); this.pictureBox1.Invalidate(); } // Draw all current drawing items when paint is called private void pictureBox1_Paint(object sender, System.Windows.Forms.PaintEventArgs e) { if(this.itemsToDraw.Count > 0) { for(int count = 0; count < this.itemsToDraw.Count; count++) { DrawingItem item = (DrawingItem) this.itemsToDraw[count]; switch(item.Type) { case DrawingItemType.Ellipse: e.Graphics.DrawEllipse(new Pen(item.DrawColor), item.DrawVal1, item.DrawVal2, item.DrawVal3, item.DrawVal4); break; case DrawingItemType.Line: e.Graphics.DrawLine(new Pen(item.DrawColor), item.DrawVal1, item.DrawVal2, item.DrawVal3, item.DrawVal4); break; case DrawingItemType.Rectangle: e.Graphics.DrawRectangle(new Pen(item.DrawColor), item.DrawVal1, item.DrawVal2, item.DrawVal3, item.DrawVal4); break; } } } }
-
kanak: Give this a try: private void AddMessage(string message) { // Make RichTextBox active this.rtbTest.Focus(); // Append Message this.rtbTest.AppendText(message); // Put the cursor at the very end of the text this.rtbTest.Select((this.rtbTest.Text.Length), 0); // Scroll this.rtbTest.ScrollToCaret(); }
-
kaisersoze: I do the exact same thing you are describing in an application I developed through manipulation of the bound DataSource as I desribed above. I take the index of the selected row in the grid and retrieve the corresponding DataRow in the DataTable and then move the DataRow up or down one position. If the user hits index 0 or Rows.Count - 1, I disable the corresponding button. If the user selects row index 0 or Rows.Count - 1, I disable the corresponding button. Piece of cake.
-
Thanks for your feedback penfold and you have made some very good points. We will be developing a Smart Client application and the business process it will be implemented into is heavily dependent on internet connectivity and communication. A mathematical modeling tool which my company uses derives a unique license from various hardware serial #'s on the install machine and communicates this license periodically to a server maintained by the software provider. The software provider reserves the right to 'turn-off' the license in the case of a contract dereliction. It is also used to verify that the software is running from a licensed machine. I was fishing more in my post for someone who had any development experience with a requirement like this and/or could point me to a good resource to begin doing some research. Thanks
-
I am beginning a round of research on a licensing scheme for a windows forms application which will begin development later this year. One ideal scenario we are shooting for is to have the application periodically go out over the pipe and talk to a Web Service on our server to validate that the application license is valid. Does anybody have any feedback from experience of implementing this type of requirement, able to point me to any helpful resources to take a look at, or point me to any third-party components that do a lot of the heavy lifting? Thanks ahead of time! :)
-
philip: You need to change top to a collection of Controls....I'll try to get the VB right: :p Dim top(panels.Count) As Control Dim count As Int32 = 0 For Each focus In panels.ToArray focus.Minimize(DockStyle.Top) top(count) = CType(focus, Control) count = (count + 1) Next Me.Controls.AddRange(top)
-
thomas: You can control how the underlying DataTable can be used in the DataGrid through manipulating its DefaultView // Data in DataGrid will automatically be Read-Only dataSet1.Tables["Table1"].DefaultView.AllowEdit = false; // Rows in DataGrid cannot be added (no '*' Row) dataSet1.Tables["Table1"].DefaultView.AllowNew = false; // Rows in DataGrid cannot be deleted dataSet1.Tables["Table1"].DefaultView.AllowDelete = false; You make want to check out ComponentOne grids. They come with all of this functionality and a lot more out of the box. I started using them last year and have never looked back since.
-
You would think that invalidating the Control in a Resize event handler would be all you needed.... if(this.DesignMode) { this.Invalidate(true); } However, I have seen enough peculiar things happen in the designer that leads me to believe it is a shot in the dark sometimes.
-
Have you overriden Paint in your custom user control? If so, that is the first place I would check for an error or complication in my code which may cause 'weirdness' in the designer.
-
thomas: What are the requirements in place that call for the use of an ArrayList and a DataSet? In my opinion, if the data needs to end up in a DataSet anyways, you should just bypass the complications of the ArrayList and use your DataSet for everything.