|
Hi Bill,
You can set the form's dock to Fill when putting Form inside Form's Control property, for auto fitting in the parent form.
One advantage is you can easily change your presentation from one way to another, for example from above, instead of putting FormA or FormB in panel, you can easily change it to show FormA or FormB as popup forms.
Also, I can easily test the form without needing to create a form to host the user control or panel, wire up all the events, etc.
Though using Form, the application may get a bit heavier.
|
|
|
|
|
This is a rant not a question.
I have 2 DGVs with approx 1000 rows each on a single form, each has 14 columns and I need to format the alignment and text of the last 6 columns.
I created this utility event that uses the cell format event to set the alignment based on the columns underlying data type (ValueType) and assigned it to both grids. Performance is not good, there is an appreciable delay when loading and filtering the grids, about 3-5 seconds
public static void dgCellFormat(object sender, DataGridViewCellFormattingEventArgs e)
{
DataGridViewColumn oCol = (sender as DataGridView).Columns[e.ColumnIndex];
string vt = oCol.ValueType.ToString().ToLower();
switch (vt)
{
case "system.int32":
case "system.int16":
case "system.int64":
e.CellStyle.Alignment = DataGridViewContentAlignment.MiddleRight;
if (!oCol.HeaderText.EndsWith("ID"))
{
e.CellStyle.Format = "#,#";
}
break;
case "system.decimal":
e.CellStyle.Alignment = DataGridViewContentAlignment.MiddleRight;
if (!oCol.HeaderText.EndsWith("ID"))
{
e.CellStyle.Format = "#,#.00";
}
break;
case "system.datetime":
e.CellStyle.Alignment = DataGridViewContentAlignment.MiddleRight;
break;
}
}
So I thought if cell formatting is slow then formatting the columns defaultcellstyle should be better performance. WRONG , setting the defaultcellstyle instead of cellformatting resulted in a delay of approx 50 seconds when loading. I suppose b/c the grid formats all the data instead of just the data on display.
[edit] Thanks to comments from darklev I moved the above formatting into the column creation process, removing the AutoGenerate columns and formatting the columns to meet my requirements. Work perfectly without the overhead. [/edit]
Last modified: 123hrs 51mins after originally posted --
|
|
|
|
|
Are you using AutoGenerateColumn=true?
Why not define the columns as what you would like, before populating the data onto the DataGridView?
|
|
|
|
|
This is a generic tool, take any DGV and any datatable and throw them together pass the result through this and you get a well formatted result. Customising a DGV for a specific datatable is not the goal, that way lies WPF.
I loathe coding twice, so I often (nearly always) build a utility method that will service the bulk of my requirements. Then in the few time it needs tweaking I do the custom formatting. As an example I had almost forgotten how to bind a data control, I have had a utility that does it since dotnet 1.
Never underestimate the power of human stupidity
RAH
|
|
|
|
|
What I meant was before you assigned the dataset to the datagridview, build the columns base on your existing logic, versus look at each cell's data type and set the alignment for that cell(you are repeating this 1000 times or how many rows in the data table).
It can still be generic to the data type of each column.
After all, each column will have a specific data type, there's no point to do the alignment on every cell/row.
|
|
|
|
|
darkelv wrote: you are repeating this 1000 times or how many rows in the data table
Your logic is impeccable - it matches mine precisely. So I set the format of the columns using the defaultcellstyle - this takes an order order of magnitude longer than setting the cell formats. This is the basis of my rant!
Actually I think you will find it is doing it for the 100 or so cells that are currently on display.
Never underestimate the power of human stupidity
RAH
|
|
|
|
|
Nevermind, you are not getting it..
You can define the columns _once_, before populating the datagridview with data.
|
|
|
|
|
Ah click, I've been binding the DGV, then changing the columns, and paying the price. So get the table, define the columns based on the table and then bind the datatable. Oh bloody hell, my utils does this it just doesn't do the datatype formatting - stupid frikking twat
Thank you
Never underestimate the power of human stupidity
RAH
|
|
|
|
|
As we can create Regions in code like
#Region "1).Declarations"
Dim con As SqlConnection
end region
similarly can we make sub blocks or sub regions with in a region
Best Of regards,
Softdev
Best Of Regards,
SOFTDEV
Sad like books with torn pages, sad like unfinished stories ...
|
|
|
|
|
The easiest way to resolve a question like this is to try it.
What can it break?
Be brave!
Henry Minute
Do not read medical books! You could die of a misprint. - Mark Twain
Girl: (staring) "Why do you need an icy cucumber?"
“I want to report a fraud. The government is lying to us all.”
|
|
|
|
|
yes could not find any sub blocks with in regions did u try and found something
Best Of Regards,
SOFTDEV
Sad like books with torn pages, sad like unfinished stories ...
|
|
|
|
|
AFAIK you can nest #region/#end region blocks several layers deep. Not sure if there is a limit.
Henry Minute
Do not read medical books! You could die of a misprint. - Mark Twain
Girl: (staring) "Why do you need an icy cucumber?"
“I want to report a fraud. The government is lying to us all.”
|
|
|
|
|
thanks i got it v can
Best Of Regards,
SOFTDEV
Sad like books with torn pages, sad like unfinished stories ...
|
|
|
|
|
But how ca we make regions in Function Bodies
Best Of Regards,
SOFTDEV
Sad like books with torn pages, sad like unfinished stories ...
|
|
|
|
|
Hello,
I'm developing a simple text highlighting editor, and I can't disable scroll bars when I call the Select(int start, int length) method of the RTB, for example The cursor is on the 40th line and I want to select an expression at line 1 and do something on that, but doing this causes the RTB to scroll to the first line and so this is considered a bug !
can anyone help me ??
Thanks,
ashkan s.
|
|
|
|
|
Is not this its default behavior which i have doubt that you can change , try to work on your selection of expression thing code it will be more better and prospective then to this scroll bar thing
Best Of Regards,
SOFTDEV
Sad like books with torn pages, sad like unfinished stories ...
|
|
|
|
|
Can you explain more ? Unfortunately I didn't understand ....
thank you,
ashkan s.
|
|
|
|
|
I'm shocked by this bug.
Create a scrollbar and in the Scroll event write some code to tell you the value of the scrollbar, ie. the text in a label etc.
What I've noticed:
1.) It is impossible for it to be dragged to the value of 100.
2.) If you slowly drag it all the way to the end of the scrollbar, you might get a value of 86 or 90, but if drag it quick enough you might get something as low as 59.
Has anyone else noticed this?
If everything was not true, would it be not true that everything is not true? So by saying everything is not true, you are automatically denying that everything is not true. Im so confused...
FreeDOS
- An open source modern
MS-DOS/PC-DOS replacement.
|
|
|
|
|
Hi,
It's not a bug, it's by design or at least that's the story on MSDN.
The value of a scroll bar cannot reach its maximum value through user interaction at run time. The maximum value that can be reached is equal to the Maximum property value minus the LargeChange property value plus 1. The maximum value can only be reached programmatically.
It is a bit odd as I don't think that Trackbar exhibits this behaviour.
Alan.
|
|
|
|
|
just change the large change Property to 1 or whatever from 10
Best Of Regards,
SOFTDEV
Sad like books with torn pages, sad like unfinished stories ...
|
|
|
|
|
Or set the maximum to (maxYouReallyWant + LargeChange - 1) which is what I do...
There are three kinds of people in the world - those who can count and those who can't...
|
|
|
|
|
I kept wondering why my Undo/Redo buttons sometimes didn't work as expected. Just noticed that toggling the WordWrap on and off is the culprit. Has anyone else encountered this?
The code below is a stripped down version just to illustrate the problem. Paste it into a form called "Form1". Drag in a RichTextBox named "rtf" and a ToolStrip. Add 3 buttons to the ToolStrip:
Set the CheckOnClick property for tb_WW to true (toggles the WordWrap in the RTB).
Here's the code:
Private Sub tb_Undo_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles tb_Undo.Click
rtf.Undo()
End Sub
Private Sub tb_UndoWW_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles tb_UndoWW.Click
If rtf.CanUndo Then
rtf.Undo()
End If
End Sub
Private Sub tb_WW_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles tb_WW.Click
rtf.WordWrap = tb_WW.Checked
End Sub
Private Sub rtf_SelectionChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles rtf.SelectionChanged
tb_UndoWW.Enabled = rtf.CanUndo
End Sub
Add some text the RichTextBox, then backspace or whatever to change it. Then toggle the word wrap a time or two. Watch the tb_UndoWW ToolStrip button. It'll disable because the CanUndo property changes to false.
Is this a bug (couldn't find it at MSDN) or am I doing something really dumb here?
|
|
|
|
|
|
|
Both of the text editors to which you provided links have the same bug I referred to above. Toggling word wrap sets the RichTextBox.CanUndo to False. The one at A1VBCode also seems beset with disappearing tool bar icons.
Is anyone else encountering this? For all I know the problem may be with my computer and not the RichTextBox. I'd love to know.
|
|
|
|