|
You do not very clearly describe exactly what it is that you are trying to do.
If I read this correctly then it appears that what you are doing is this:
left side has a treeview with items in it.
when you click on a value in the treeview you populate the other side with a control that is populated with the data related to the value chosen in the treeview.
I also am guessing that the problem is that the user control doesn't dock in the other side of the SplitContainer.
It is up to YOU to do that. Do the same thing programmatically that you would do in the designer.
1) put control into container
2) tell the control how you want it docked.
... era does not rock if era cannot clearly explain his problem.
|
|
|
|
|
I have a small invoicing application in MS Access that I have started converting to SQL Server 2005 and WinForms. This is a very small application, and I should have full functionality in two or three days, with all bells and whistles by the end of next weekend.
I'm in two minds whether to sweat it out and implement databinding, or just do what I know best and code all my own data access, using DataTable objects as 'proxies' for detail grids etc. All I know about data binding is the problems I've had previously when changing column names etc. Visual Studio 2005 seems to remember things you want forgotten in very secret places.
However, this is a great opportunity for me to overcome my lack of experience and learn to deal with the problems I have encountered before. What is the general opinion on this? At least I now have internet at home, so my friend Google will be looking over my shoulder when I attempt a data bound application.
BTW, I am also moving forward in learning NHibernate, but I feel the overhead of learning something at that level, outside of the intrinsic .NET tools, is a little too much for a project of this size.
Calling all South African developers! Your participation in this local dev community will be mutually beneficial, to you and us.
|
|
|
|
|
Mostly, databinding is a good idea. As Charles Petzold[^] puts it in his WPF book[^], there are less moving parts in your program that way. Lesser code means lesser stuff that can go wrong! But yeah, VS is notorious for doing some pretty crazy things when using the designer to implement databinding. I mostly stay away from the designer for stuff like this, except when I am trying to quickly prototype something.
|
|
|
|
|
I'm trying to monitor keypresses for a sequence that indicates the characters following the sequence belong in my BarCode control, so when the sequence is detected, that Control receives focus. How do I maintain a fixed length buffer of key presses, compared to the following code. My buffer should only be as long as the sequence I'm looking for, but I don't know how to shift the incoming key presses through the buffer.
private readonly string SCAN_START_SEQ = new string(new char[] { (char)2 });
private StringBuilder keyBuffer = new StringBuilder();
private void ScannerInputForm_KeyPress(object sender, KeyPressEventArgs e)
{
keyBuffer.Append(e.KeyChar);
string buff = keyBuffer.ToString();
if (buff.EndsWith(SCAN_START_SEQ))
{
keyBuffer.Remove(0, keyBuffer.Length);
e.Handled = true;
textBarCode.Focus();
}
}
Calling all South African developers! Your participation in this local dev community will be mutually beneficial, to you and us.
|
|
|
|
|
The lazy way is to have an edit box, set the maximum text length and use an event handler for when the limit is reached then readt the text.
This has the GUI advantage that the user can see the barcode is scanned, that's how I've done it in the past.
|
|
|
|
|
I need to detect the sequence before the barcode textbox is filled. My buffer starts empty, and lets say I defined my scanner to send '02x03x' before the main barcode. When I receive the first char, I add it to the buffer and check if the buffer ends with '02x03x'. It doesn't yet, so I keep it. When I receive the next char, the 03x, I do the same, but the compare passes this time. I then empty the buffer, and move focus to the barcode texbox. But now, until the next '02x03x', my buffer is going to get quite full if the user types a lot and scans little. I don't want the user seeing anything of this buffer.
Calling all South African developers! Your participation in this local dev community will be mutually beneficial, to you and us.
|
|
|
|
|
This sounds like it's more about the architecture of the application than the scanner.
If you check for keys received by the application then you can detect the 02x03x sequence there and clear the buffer, move the focus etc.
This could be done using accelerators for example.
Elaine
|
|
|
|
|
You're right, it is about the application, not the scanner. That's why I moved it here.
I'm a little concerned about the potential size of the buffer before a 02x03x is detected, so when I get home I'm going to look into a either a circular buffer, or a background thread to clear the buffer during states where a scan should not occur.
Calling all South African developers! Your participation in this local dev community will be mutually beneficial, to you and us.
|
|
|
|
|
Sorry, I don't see why you need a buffer at all.
Step 1: start sequence received as a pair of accelerators
Step 2: set focus to edit box
Step 3: use EN_MAXLEN event to detect when the bar code has been scanned (no terminator needed)
Step 4: read edit box and get the barcode
|
|
|
|
|
Elaine, I want to be able to define any sequence of characters as my signal for scanner input, where using accelerators would limit my options there. I also want to cater for EAN-8 as well as 13, so the TAB terminator is perfect, as it will raise the Leave event of my barcode edit box when any code, of any length, is read.
My next challenge is a nice to have, which is a global keyboard hook that ignores all key inputs between my scan signal and terminator. You get some really funny effects scanning when other Windows applications have focus. Windows pop in and out etc.
Calling all South African developers! Your participation in this local dev community will be mutually beneficial, to you and us.
|
|
|
|
|
Hi Brady,
if you want to recognize a specific string (SEQ) the only thing you need
is a buffer of length SEQ.Length; since you need the string value for every
character you append, it is not useful to have a StringBuilder.
Hence use a string (say buf, initialized at "") and do:
buf=buf+e.KeyChar;
if (buf.Length>SEQ.Length) buf=buf.SubString(buf.Length-SEQ.Length, SEQ.Length);
if (buf.Equals(SEQ)) ...
Luc Pattyn [Forum Guidelines] [My Articles]
this months tips:
- use PRE tags to preserve formatting when showing multi-line code snippets
- before you ask a question here, search CodeProject, then Google
|
|
|
|
|
Luc, it's easier to say,
if (buf.EndsWith(SEQ)) ...
I was doing that before, but I worried about the size of buf just using a string. If the user doing data capture without scanning, bu could get pretty big, and unless there is some internalisation magic I don't understand, every key press will create a new string . I use a StringBuilder so that I can remove the first character before appending the last. It seems to have acceptable performance.
Calling all South African developers! Your participation in this local dev community will be mutually beneficial, to you and us.
|
|
|
|
|
Hi Brady,
Brady Kelly wrote: every key press will create a new string
So does your statement string buff = keyBuffer.ToString();
Brady Kelly wrote: I worried about the size of buf just using a string
My statement if (buf.Length>SEQ.Length) buf=buf.SubString(buf.Length-SEQ.Length, SEQ.Length);
limits the string length at all times (to 2 chars in case SEQ=x02x03).
If you don't want to do all the buffer stuff, there is one (slightly more complex)
alternative using a state machine, which basically remembers how many characters of SEQ
have been matched so far. So in one implementation it would use an int state;
and basically do:
if (e.KeyChar==SEQ[state]) state++; else state=0;
if (state==SEQ.Length) {
state=0;
... we got a match
}
the above code however is incorrect as soon as SEQ contains repeating characters though;
if you must cope with the general case it becomes much more complex...
Luc Pattyn [Forum Guidelines] [My Articles]
this months tips:
- use PRE tags to preserve formatting when showing multi-line code snippets
- before you ask a question here, search CodeProject, then Google
|
|
|
|
|
Ooh, I really didn't read your first reply properly.
Thanks, I'll look into the state machine a bit later in the project, when I create a base form for all forms that use a scanner.
Calling all South African developers! Your participation in this local dev community will be mutually beneficial, to you and us.
|
|
|
|
|
Anyone can point me to some Windows Form Free DataGrid-like control that can support Master / Detail View (a hirarchical sub-rows view, that is), if there is any? I've been searching google but couldn't find anything free :P.
Thanks.
|
|
|
|
|
Mr. Candyman wrote: I've been searching google
Interesting[^]
|
|
|
|
|
Thank you, but I was looking for a control to use in a Windows Application, and all I can see is for web app.
|
|
|
|
|
Mr. Candyman wrote: but I was looking for a control to use in a Windows Application
Interesting[^]
|
|
|
|
|
Thanks, but again I could'nt find anything useful. What I really need (if possible) is a control like the asp.net details-view (one single datagridview) but for a windows form and free. Some examples where interesting but mostly used 2 datagridviews, and I can do that myself
|
|
|
|
|
i am creating a customized messageBox to add the images and the icons that i need. I have a little problem is that the message and the lable that will hold it.
I need to make the lable to expand vertically as much as the text is, but not horizontally, how?
thanks for your help
abdelhameed81
|
|
|
|
|
If you set the height of the control, I'd imagine it wouldn't get any higher.
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 )
|
|
|
|
|
Hello to everybody,
I've got a problem with datagridview and generics, here's the piece of code :
<br />
dataGridView1.ReadOnly = false;<br />
List<Product> myProds = new List<Product>();<br />
<br />
myProds.Add(new Product("Prod 1", 1, 1));<br />
myProds.Add(new Product("Prod 2", 2, 2));<br />
myProds.Add(new Product("Prod 3", 3, 3));<br />
<br />
dataGridView1.DataSource = myProds;<br />
<br />
myProds.Add(new Product("Prod 99", 99, 99));<br />
on video I've 3 rows but in the datagrid.datasource I've 4 items.
Where do I do wrong?
Thanks in advance
Paolo Ponzano
|
|
|
|
|
As this is windows forms, there's no databind command, the grid is bound at the point that you set the data source. So, the objects you add after, are there, but the grid does not rebind every time you add an item.
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 )
|
|
|
|
|
so what should I do?
Thanks
Paolo
|
|
|
|
|
Reset the datasource after you have added the new items.
Deja View - the feeling that you've seen this post before.
|
|
|
|