|
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
|
|
|
|
|
OpenFileDialog cannot be shown from any thread other than your main GUI thread. You cannot open it from a background thread. You'll need to change your program accordingly (and by the way, you shouldn't be showing other forms from background threads, either).
It has become appallingly obvious that our technology has exceeded our humanity. - Albert Einstein
|
|
|
|
|
many thanks for your help.
y
|
|
|
|
|
I have a parent child relationship, on DocumentID, between an invoice and invoice lines. A form displays invoice fields and has a grid for invoice lines. The grids BindingSource points to the Invoice Binding Source, and it's DataMember to the relation, so I think this is correct.
Now, if I leave the relation type to Only Relation, the DocumentID in my new Invoice is -1, and the DocumentID in my Invoice Lines grid is also -1, but the Line record remains -1 after being written to the database. So, I think maybe I should make the relation a constrain as well and add a cascade update, but then I get an error that -1 doesn't exist in the parent table, even though the Invoice datatable DocumentID is -1.
|
|
|
|
|
With an XmlDataDocument (based on a DataSet and an XmlDocument) and a BindingSource, I've found that I have to add a handler to AddRow for the child and wire up the child's FK to the parent manually. Don't know if that helps in your case.
However, obviously (or it should be obvious) the invoice DocumentID has to exist. If you're using identities, you'll have to save the invoice row first, get the DocumentID, put it into the invoice line FK's, and save the invoice lines.
Marc
|
|
|
|
|
Hi Mark, thanks for the advice, but as I have it, establishing a DataRelation between the two tables should be enough for ADO.NET to know to cascade the new parent primary key value to the new child records.
In fact, it is enough, but I have to call EndEdit after calling AddNew on my parent binding source. This makes the -1 PK availble to child FK, and the relation is established. Now when use the table adapters to update my DocumentTable and then DocumentLine table, the automatic cascade of the PK to the FK works perfectly.
|
|
|
|
|
Brady Kelly wrote: but I have to call EndEdit
So that was what was missing?
Brady Kelly wrote: Now when use the table adapters to update my DocumentTable and then DocumentLine table, the automatic cascade of the PK to the FK works perfectly.
Huh. That's pretty impressive. I've never actually seen that behavior--I'll have to revisit some code I recently finished where I had manually assign the FK. It'd be useful to reduce this whole issue into a small, simple, test case.
Marc
|
|
|
|
|
What is the best way to do this? Implement the content forms as controls, and factor the commonalities out into a host form, or to inherit from a base form. Somehow I think the latter is not as simple as it sounds, but I haven't tried either yet, I'm just checking.
|
|
|
|