Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 6 years ago.
Improve this question
I'm a real dummy at UI building, so I'm wondering - what .NET winforms control would be best to use if aiming to display tweets in a list fashion that updates with like boxes which contain the text of the tweet and its metadata below it. Is there a specific winforms list function for this type of thing? Or do you recommend I look for/use a third party winforms control? Thanks! Hope my question wasn't too silly.
UPDATE: I am getting indication from numerous responses that it would be better to just build a simple winform control myself, but can anyone point me to a tutorial for doing so? Also, if i were to build such a control, does there exist a convenient built-in control for making like a list of custom controls that is scrollable - maybe Panel? Thanks in advance!
I'd build a user control that would display the information for a single tweet. I'd then repeat that user control in a panel.
You could just use the same layout in your user control that is standard for "tweets".
Left justified picture box to display the user image.
LinkLabel for user name.
Label for tweet text.
Update: Here are a couple pages on UserControls
http://msdn.microsoft.com/en-us/library/a6h7e207(VS.71).aspx
http://www.akadia.com/services/dotnet_user_controls.html
Create a usercontrol using the designer and also a Tweet class that is
just a dumb data structure to hold each tweet's information. Also create a Tweet
property on the custom user control that would handle setting the tweet and assigning information
to the standard controls contained in it (Labels, Textboxs, PictureBox, etc).
In the form where you want to host your user control create a panel that is empty. Somewhere in your code you
would do something similar to this code block.
pnlHost.Controls.Clear();
List<Tweet> tweets = new List<Tweet>();
//Populate your collection of tweets here
foreach (Tweet tweet in tweets)
{
TweetControl control = new TweetControl();
control.Tweet = tweet;
pnlHost.Controls.Add(control);
control.Dock = DockStyle.Top;
}
Hi I'd go for a third party grid control from companies like Infragistics, DevExpress or Telerik. Another option would be to build a usercontrol that is able to display one post and put that control into a vb.net repeater control (which ships with the vb.net powerpack). However I'm not sure how good the last solution actually works, as I just read about it, but never tried it.
Try using DataGridView (and a DataTable behind it) and overwrite the CellPainting event to draw the tweets the way you like it.
Edit
I think using a custom control is a bit heavy just to display the tweets. Basically this depends on the desired functionality of the displayed tweets - what would you like to do with them. For example, if you just want the user to click the tweet and then redirect him to some webpage in the browser then the DataGridView will do just fine since you can attach this action to the CellClick event. Plus you already have the sorting/searching capabilities of the DataTable (and the related DefaultView)behind it. Hell, you can even attach a ContextMenuStrip to the tweet and have unlimited options with the RightClick.
On the other hand if you need some functionality that is not available in the DataGridView (for example, you would like 5 different buttons at the bottom of the tweet and 3 checkboxes on the right) then the custom control would do you better because you could build practically everything you wanted. In this case OG explains this nicely.
Try listbox, it's easy to use and seems like it will suit your needs.
Related
Closed. This question needs debugging details. It is not currently accepting answers.
Edit the question to include desired behavior, a specific problem or error, and the shortest code necessary to reproduce the problem. This will help others answer the question.
Closed 8 years ago.
Improve this question
I want to create a custom control using Infragistics UltraGrid control. I want to add a button on top of the UltraGrid which exports data as excel. You can get better idea by viewing below image.
This grid is used many times in my project so that i need it in a user control. I have tried to create it but when i add this control in my project i cannot access all actual properties of that UltraGrid.
please help...
You are creating a composite control. Normally this means that you can't access the composing controls from the form where you want to position your usercontrol. Usually you need to provide the code to access the underlying properties and events of the controls that compose your UserControl.
For example, supposing that you want to change the caption of the UltraWinGrid inside your user control, you should write a get/set property like this in the code of the UserControl.
public string GridText
{
get
{
return ultraGrid1.Text;
}
set
{
ultraGrid1.Text = value;
}
}
As you can imagine, this is not a trivial task with a control like the Infragistics UltraWinGrid that has probably thousands of properties. Not to mention the long list of events.
See here a tutorial from Microsoft about building a Composite Control and that explain the problem with properties of the underlying controls.
A simple workaround (NOT RECOMMENDED) could be to change the property Modifiers of the UltraWinGrid and of the button from Private to Public. In this way the grid reference is available from the properties of the UserControl and you can program it as before.
userControl1.ultraGrid1.Text = "My User Control";
However this is not recommended because you give full access to the composing controls and this, in certain situations, could be not desiderable. It largely depends on your using scenario.
I am working on a WinForm based applications(Yes I don't know WPF) and want's a dashboard like panels in it. Picture given below
Each panel will have a title and records from Database and some action controls. How could this be achieved? I don't want to use GridControl as I don't want to show Excel like spreadsheet here. How could this be achieved?
It sounds like you want to make a UserControl, possibly coupled with an automatic layout panel like FlowLayoutPanel.
Simply speaking, you would create a UserControl with whatever properties and events you require (i.e. in your example you might have a Title property and a Data property), and any events you need to respond to (e.g. you might have a button that you provide a wrapper event for). Then you can add the control to your existing form as you would any other standard control.
As far as displaying data in list form goes, one suggestion is to use a Panel and dynamically add Labels to it. Another idea could be just a simple Label with line breaks in the Text.
ASP ListView can be easily made to change the view of item on lick, like display a table but when the item is clicked expand it and show details in some custom format that differs from table. (e.g. some multiline text)
Have anyone seen any free control, or a tutorial to make one with similar behavior but for winforms?
A quick web search found this: http://www.componentowl.com/better-listview.
I'm sure a further search would reveal more at various budgets and functionality.
I'm working with a GUI in PowerShell and trying to make the form such that, after the form is built, the user can interact with the part of the form (+/- button) to dynamically add a group of controls to the form underneath of the existing set.
As an example, there will be a combobox (drop-down) to select a parameter and then a text field to fill in the value for the selected parameter.
What I'm looking for is a way to dynamically add that group of controls to the form when the user clicks the plus button. My current attempts have failed. I've tried pinning the controls inside of a TableLayoutPanel and a Panel object but can't seem to get the items to appear in the first place and then appear in some semblence of order. Is there a GUI object that I can pin the controls to that will just auto-dump the next row of controls below the existing or do I have to figure out the calculations off of the docked parent and offset the Y-values?
Does anyone know a PowerShell accessible Windows form control that would support this type of additions?
One of my attempts is psoted here: .NET 4 (WinForms) Dynamic Form Control Creation in Powershell
Any help is greatly appreciated.
Maybe you could use FlowLayoutPanel. Here is the sample script for using FlowLayoutPanel in Powershell
It's not Winforms, but there is a new module up on Codeplex called ShowUI, which enables you to create WPF based UI's in PowerShell. Take a look at http://showui.codeplex.com. There is some examples up there on using Grid controls and automatic layouts, that I think could meet your needs if you are willing to jump into WPF.
Got the answer from a Microsoft PowerShell forum Moderator:
http://social.technet.microsoft.com/Forums/en-US/ITCG/thread/b2c8abeb-3ae6-4936-9bef-a50a79fdff45/
it's the datagridview object that needs to be used.
Can't you simply build your form (for example with Sapiens free editor tool) with all the controls invisible, and then according to the user choice make them visible ?
I'm trying to learn WPF and was thinking about creating a simple IRC client. The most complicated part is to create the chat log. I want it to look more or less like the one in mIRC:
or irssi:
The important parts are that the text should be selectable, lines should wrap and it should be able to handle quite large logs.
The alternatives that I can come up with are:
StackPanel inside a ScrollViewer where each line is a row
ListView, since that seems more suitable for dynamic content/data binding.
Create an own control that does the rendering on its own.
Is there any WPF guru out there that has some ideas on which direction to take and where to start?
I suggest you start with a good object model independent of the UI, and then try a multi-line TextBox or a RichTextBox.
Whether these will suffice will depend on exactly how long you want the log to be able to get. If you run into performance issues, you may need to look at virtualization.
First of all, you should consider if you want to select only entire row (like in a listbox), or if you want to select certain characters from a row (like in a textbox).
In the first case, I think a ListView or even a ListBox should be enough, both of them support virtualization when bound to collection and there should be no problem with huge amounts of data. A stack panel inside a ScrollViewer is a little bit like reinventing the wheel for this case and creating a new control is not a very inspired approach in my opinion (as the functionality you want can be achieved with the existing controls, in WPF).
In the second case, if you want to select some text inside of a line, or if you want word wrapping for your longest lines in the log and want to select individual parts of the wrapped lines, then you need to use a control more oriented on displaying text. Kent already suggested a RichTextBox, I would add AvalonEdit control or even the WebBrowser control in which you directly modify its HTMLDocument.
I would suggest to use RichTextBox too, and store items in a log file or database, if you run into performance issues.
Another solution is to use the WPF WebBrowser control and modifiy its HTML content with:
webBrowser.NavigateToString("<HTML><H2><B>This page comes using String</B><P></P></H2></HTML>");
More information about using WebBrowser control