Devexpress grid details grid with a bar - c#

I'm trying to figure out how to implement master-detail relationships between 2 tables in order to have a grid with grid details, just like this example
Now I got the same result as shown in the above link, but now I want to add a button 'Add' in order to add new records but it doesn't seem so easy.
I tried to create a control that contains a grid and a bar with buttons 'add' and 'edit' and create a relationship between it and the main grid but that didn't work either ..
Can anyone give me a hint how to do this ? Any help is appreciated :)

Have you tried using the Data Navigator?

If I've understood you right, you want to have a master detail grid, and above it, a bar that contain buttons to Add and Edit your items. If so, You can do the following :
If you wish to put your bar in the top of the form, use a bar Manager.
Otherwise : Try a Panel control, and in it, you put a StandAloneBarDockControl (enable you to put your bar in other places than the top of the form), and than, use the bar manager and the xtragrid controls.

Have you tried using the Embedded Navigator? Or is that no solution for you? Further you can build in a ContextMenuStrip. It is not exactly what you searching for but maybe it helps.

Related

Winforms UI Dynamically Displaying Parts

I came across a tutorial and some example code for an audio converter. You select the format you want to convert to from a drop down, and when you do all sorts of options appear in a previously blank area, different options based on the format you choose. It's called Audio Converter .NET and is from same author as Audio CD Ripper .NET. I can't find the tutorial, but here is a screenshot.
See how on the right there is extra controls that are not on the left. I was experimenting trying to add another category. I added it to the dropdown, but am unsure how to make it so certain fields come up when it is selected.
I understand that they create those controls for those items, but I don't see how they call the correct one when the combo box selects something. I see controls are created, but if I try to duplicate the controls into another entry in the combo box they don't show up for either the new or old one I was duplicating from.
What's the best way to go about achieving something like this?
Thanks
The easiest way is to create the controls needed for every option in the dropdown inside a panel, and simply turn it's visibility property from false to true whenever it's corresponding option is selected using the combobox's SelectedIndexChanged event handler. (And don't forget to turn the current visible panel's visibility to false)

Expanding and contracting DataGridView

I am currently working on a project that displays user data in a grid, each user has a total and when clicked expands out to show the sub items that make up that total and they can be expanded again to show even more details.
I currently achieve this by using a DataGridView with its data bound to a DataTable, I hide the sub items for each user in the "RowsAdded" event and then just show/hide them as the main user lines/sub lines are clicked.
The Main problem with this is the scroll bar jumps a lot when data is changed and I require it to only move when the user wants it to.
I also have a requirement that no line must ever be covered and the parent lines should show totals of the values in the child (I can do this part manually the more important part is that its not a grouping like with a outlook style list).
My question is: Is there a better way to have expanding entries in a table format? And if hiding and un-hiding is the only way then any idea how to fix the scrolling problem?
I have tried hiding and showing lines as I have already said and I have also tried hiding and showing another Control (in this case another DataGridView) the problem with this approach is that it covers the other rows as I have yet to find a suable way to pad out a space for the control to be in.
You can use the following code to eliminate the scrolling animation.
dataGridView1.ScrollBars = ScrollBars.None;
// Do your show/hide on your datagridview rows
dataGridView1.ScrollBars = ScrollBars.Both;
In the End there was no satisfactory way to do this with winforms so I was forced to swap to WPF and I had everything running in about 2 hours.
My end solution was to use a DataGrid with rowdetails that contain a DataGrid.

How to show same control in different pivot item?

Is this possible to show same control in every pivot item.
So I think my options are
1.Change the pivot header but not changing the pivot actually.
2.Add the control as a child control of a grid in another pivot item.[which i think not possible]
3.Just ctrl+c and ctrl+v the design with different names of the control[i don't want to do this].
Is there any other way? Option 1 or option 2 is possible? If yes how?
Please Help.
In your case what makes more sense is to create a UserControl.
I suggest that you create a UserControl from the Grid. It is easy to do in Blend. Open your project in Blend, expand the page contents in the Objects and Timeline panel, right-click on the Grid and select Make into UserControl. Blend will create a UserControl class that you can reuse in each PivotItem.
Taken from MSDN Forums
//Now you should be able to do something like this.
MySecondPivotItem.Content = new MyUserControl()
And that's all. Also you can create the PivotItem on the flight and add it to the Pivot, like this: (Assuming that pivotMain is your Pivot)
pivotMain.Items.Add(MySecondPivotItem);
Hope this helps

How to make popup window auto populate with contents in cell

I have a data grid displaying results from a sql database. What I want to do is make it so that when I double click on a cell in the datagrid, a new window appears where that cell can be edited. I also would like to have all the info for that cell to be autogenerated into editable fields when the cell is double clicked. Any help or links to tutorials is appreciated. Thanks.
Try this DataGridView.CellDoubleClick Event
Did you consider using data binding? Simply put, you can bind your items list to DataGrid, and current item (eg. selected/double clicked) to your edit form's controls (TextBox, Label and whatever else you might have there).
Here are good starting points for windows forms: #1, #2. They cover problem you're facing. You can find data binding tutorials for ASP/WPF easily too, but especially first link covers entire concept pretty well.

adding a windows form object to listbox

I'm creating a twitter client in C#.
I want to put every tweet as an element of a listbox.
I created a windows form that represents a tweet(it has a picture, and labels).
My problem is that when i can't see the tweets when i add them to the listbox. After adding 3 tweets(windows form objects), the listbox has 3 blank elements in them, but i can't see anything of it.
How can i add a windows form object to a listbox?
(these forms are working fine, because i can see them if i use the ShowDialog method)
please help
You can add a Form object to the ListBox.Items collection but the only thing you'll ever see is the type name of the form. ListBox is not capable of rendering controls as its items.
The efficient solution is to implement the ListBox.DrawItem event and custom draw the tweet. There's a good example of such an event handler in the MSDN Library documentation for the event.
The slow solution is to add controls to a Panel's Collection property with its AutoScroll property set to true. That cannot be a form, it must be a UserControl.
You may want to look into implementing it using WPF. Where you can pretty much put anything inside a listbox.
Some thoughts:
You'd do better to work with custom controls, rather than a whole form
A listbox can't have controls on it... consider a ListView: http://www.codeproject.com/KB/list/ListViewEmbeddedControls.aspx
Some example code of what you're trying will help us zoom in on what you're doing
HTH,
James
I don't think ListBox can display anything but a text string for each element, so you won't be able to see an image of each form if that's what you were hoping for. You might try using FlowLayoutPanel instead to manage a list of controls.

Categories

Resources