|
graag gedaan.
Luc Pattyn [Forum Guidelines] [My Articles]
This month's tips:
- before you ask a question here, search CodeProject, then Google;
- the quality and detail of your question reflects on the effectiveness of the help you are likely to get;
- use PRE tags to preserve formatting when showing multi-line code snippets.
|
|
|
|
|
is there is any simple coding for docking and floating window(Form) in c#....
regards,
ALGATES..
|
|
|
|
|
Hi ALGATES,
You need to do it with a custom control. Take panel control and add the controls you want in it. Then you need to hide/show it on MouseEnter event of the label you're defining.
There are few dockable controls on the market that you can buy if you don't
want to build your own. Also there is something ready on the codeproject:
http://www.codeproject.com/KB/miscctrl/magicdocking.aspx?target=dockable%7Ccontrols[^]
I hope this helps .
Regards,
John Adams
ComponentOne LLC
|
|
|
|
|
I'm busy creating an extended ComboBox control, called for now, DropDownList. My reason for the extension is to be able to optionally insert a first item, such as "Add new Customer...", with any data source. I'd like some opinions, please, on how I currently achieve this.
I have a DropDownListItem, which has two properties, ItemType and ItemObject. Then, I hide the base DataSource property, and in its replacement setter, I call a MergeDataSource method. This creates a List<dropdownlistitem>, with one Object type item for each object in the new data source, plus one Prompt type object for the initial "Add new Customer...", and I set the base.DataSource to this new list.
I also hide the Items property, and in the replacement getter, I create a fresh ObjectCollection, but without the prompt items, i.e. only the items from the original data source collection. I see minor potential problems here, as code that expects to manipulate the Items collection will not have access to the actual, current Items collection. However, it is illegal to modify the Items collection while the DataSource property is set anyway. When the DataSource is null, I just return the base.Items property.
|
|
|
|
|
If I understand correctly, you add a prompt type object as the first item. Won't comboBox.Item[comboBox.SelectedIndex] (the new one) returns the wrong item as seen from the UI?
|
|
|
|
|
Yes, that is something I've been worried about. Thanks for mentioning it.
I have never needed to access a selected item through the Items collection, however. I always use SelectedItem or SelectedValue, and I think I could get away with hiding these if necessary. Maybe I should not hide the Items collection, but add another DataItems property that returns the filtered collection.
|
|
|
|
|
No problem, I'm hiding SelectedIndex as well, and returning an offset index that provides correct item in my replacement collection. The 'artificial' entries are completely hidden from the clients of my drop-down, except for the events they raise when selected.
|
|
|
|
|
Oh the joys I had implementing the same thing last year. I did get it finished in the end and they haven't complained yet so I assume it's still working. I'll see if I can dig up the code and modify it (it had some stuff which I can't disclose and which did extra things you won't need). Drop me an email so that I can send you the stuff once I find it.
|
|
|
|
|
I'd like to scroll two richtextbox simultaneously in a Visual studio CLR Windows Form Application, can someone point me in the right direction..
I've tried invoke methods but don't really have much idea about it, i was planning on overriding events is that a good idea.. tnx
|
|
|
|
|
It's really the only idea. You need to catch the scroll event in one textbox, and scroll the other one so it keeps up.
Christian Graus - Microsoft MVP - C++
"also I don't think "TranslateOneToTwoBillion OneHundredAndFortySevenMillion FourHundredAndEightyThreeThousand SixHundredAndFortySeven()" is a very good choice for a function name" - SpacixOne ( offering help to someone who really needed it ) ( spaces added for the benefit of people running at < 1280x1024 )
|
|
|
|
|
thanks for you reply, but can you tell me what particular method to use....
i was trying to use invoke methods and here is my code:
#define SB_VERT 1
#define SB_THUMBPOSITION 4
#define WM_VSCROLL 0x0115
[DllImport("User32",EntryPoint = "SendMessage")]
static bool SendMessage(IntPtr hwnd, UInt32 Msg, Int32 wParam, Int32 lPAram);
[DllImport("User32",EntryPoint = "GetScrollPos")]
static int GetScrollPos(IntPtr hwnd, int nBar);
private: System::Void richTextBox1_VScroll(System::Object^ sender, System::EventArgs^ e) {
int a;
a = GetScrollPos(richTextBox1->Handle,SB_VERT);
SendMessage(richTextBox2->Handle,WM_VSCROLL, 0x1000 + SB_THUMBPOSITION * a, 0);
}
I can't determine if the message is really being posted in the message queue is there any way to see that?
The program compiles and run, but they still won't scroll simultaneously.
modified on Wednesday, February 27, 2008 8:43 PM
|
|
|
|
|
After 4 or 5 years in the ASP.NET world I'm about to embark on a new LOB WinForms application and I wondered what the current thinking was in terms of GUI design and implementation?
Any suggestions? I'm severely lacking in inspiration at the moment
Cheers
James
|
|
|
|
|
Look at other applications. I'm doing a very small POS application, so I downloaded MS Office Accounting Express; it's free. Then I looked at the layout of their invoice screen, said I like this but I don't like that, and quickly came up with my own. It's not copying, just looking for inspiration.
|
|
|
|
|
I am using visual inheritance which is really helpful to create uniform design between forms.
|
|
|
|
|
I have several ComboBoxes on a form that are bound to BindingSources. The only code I have is code to set their SelectedIndex properties to -1, to force the user to make a selection, in favour of accidentally using the first item in a list. This code has no effect in my form's Load event, so I have been forced to start a Timer at the end of the Load event, and then on the Timer's Click event, set the SelectedIndex properties. Can anyone explain this, and maybe offer a more elegant solution?
|
|
|
|
|
Insert an "empty/null row" as first item in your source, instead of using -1 to signify value not selected. Have the UI to verify that the combo box has value selected before you save it.
|
|
|
|
|
That was one of my options, but I find setting SelectedIndex a bit tidier that messing with the list domains. Alternatives in this direction are inserting the null value programmatically though, then I would be more comfortable working with an unchanged data source. I would do that in a derived ComboBox control, overriding one of the data binding methods.
I will eventually do that anyway, as I also want a 'Create a new <entity name="">...' as an option in all my drop-downs as well. This must also be 'artificially' inserted and trigger an event that tells the Combo's container to initiate the Create action for that entity.
|
|
|
|
|
By inserting the empty/null row, i mean programmatically, not into your data.
By the way, the user won't be able to unselect a selected combobox item, if SelectedIndex = -1 method is used, right?
|
|
|
|
|
Yes, but I don't have any code where I populate the lists, where I can inject another entry. If I did, I would have, but as it stands, simply setting SelectedIndex to -1 seems less complicated for extra code than inserting a list item.
|
|
|
|
|
This is a known bug in the WinForms combobox. Try setting SelectedIndex = -1 twice (don't ask...)
It has become appallingly obvious that our technology has exceeded our humanity. - Albert Einstein
|
|
|
|
|
Hi all,
pls help me
in my application using C#.net (window form) i need to save a .txt file. but if the same filename exist i need to save it as a new filename.
i have searched in net but could only find deleting existing or overwritting on the file.
pls help to get some solution
|
|
|
|
|
u can use GUID(Global Unique Identifier) for saving the text file with unique name
|
|
|
|
|
One very simple approach I take is simply create a while-loop that increments an integer, appends it to the filename (without the extension, of course), and checks for existence (after re-appending the extension). So long as that filename exists, I increment the variable again and try the next number.
Remember to include a failsafe in case the loop accidentally runs forever. Limit it to 10 or 100 iterations for example. I suppose a for-loop would be more convenient in this case then, but a while loop is more syntactically meaningful.
It has become appallingly obvious that our technology has exceeded our humanity. - Albert Einstein
|
|
|
|
|
One of the System.IO classes, I think it is Path, has a method that returns a unique file name.
Christian Graus - Microsoft MVP - C++
"also I don't think "TranslateOneToTwoBillion OneHundredAndFortySevenMillion FourHundredAndEightyThreeThousand SixHundredAndFortySeven()" is a very good choice for a function name" - SpacixOne ( offering help to someone who really needed it ) ( spaces added for the benefit of people running at < 1280x1024 )
|
|
|
|
|
Hi
I have a main form which opens a thread that opens a new form.
in the new form i'm trying to open an OpenFileDialog.
when i'm trying:
"if (projectFormOpenFileDialog.ShowDialog() == DialogResult.OK)"
when running at debug mode i'm getting:
"Current thread must be set to single thread apartment (STA) mode before OLE calls can be made. Ensure that your Main function has STAThreadAttribute marked on it. This exception is only raised if a debugger is attached to the process..."
i have declared [STAThread] in the mainform function that opens the new form, also on the event that invokes the openfiledialog function.
help on this will be most appreciated
thanks,
Yohay
|
|
|
|