|
Yes you are correct.
It appears that calling _TextChanged everytime resets the focus
E.G.
private void textBoxFirstName_TextChanged(object sender, EventArgs e)
{
if (textBoxName.Text.Length > 4)
{
getAutoCompleteSuggestions();
}
}
I have changed it to
if (textBoxName.Text.Length == 4)
To solve this
It does seem to crash a lot too in debug but I will save that for another day
|
|
|
|
|
Is there any specific need to display the autocomplete suggestions only after 4 characters?
जय हिंद
|
|
|
|
|
It was to keep the selection down to something reasonable. All works now thanks for your help.
|
|
|
|
|
I'm using the propertygrid control to display a small class (the class represents program settings) which contains a System.Drawing.Color, and some other properties.
When you click the dropdown next to the color and click a color... everything works fine.
The problem is if the user uses the Up and Down keyboard keys to change the color. When they do this the little color preview square next to the name of the color does not update until the Enter key is pressed.
I tried just using SendKeys to send Enter when the PropertyValueChanged event fires but unfortunately the control looses focus of the selected property.. which is exactly what happens when the enter key is pressed normally. But it's unnatural because your pressing the down and up keys to scroll through the colors... so ya Enter-key-sending is not the way to go.
Is their anyway to force that little color preview box to change to match the color name next to it
|
|
|
|
|
I sent the Tab key as well after enter and it worked fine for me. There might be a decent way to achieve this that I am not aware of.
This way:
SendKeys.SendWait("~");
SendKeys.SendWait("{TAB}");
जय हिंद
|
|
|
|
|
Excellent your code worked perfectly. Here's full code for anyone else that finds this thread.
private void propertyGrid1_PropertyValueChanged(object s, PropertyValueChangedEventArgs e)
{
SendKeys.Send("{ENTER}~{TAB}");
}
|
|
|
|
|
actually this will work to:
private void propertyGrid1_PropertyValueChanged(object s, PropertyValueChangedEventArgs e)
{
SendKeys.Send("{ENTER}{TAB}");
}
|
|
|
|
|
FocusedWolf wrote: SendKeys.Send("{ENTER}{TAB}");
This alone is enough. Actually "~" is just another way to send Enter key.
जय हिंद
|
|
|
|
|
|
Hi ,
I am usign propertygrid in my application . I am using one class i that i m having " Caption " prooperty. i am
I wrote this code to Keyboard UP left,right down keys to work . In that i am having the code to move the controls . according to below condition i am highlighting the property .
Private Sub PropGrid_Enter(ByVal sender As Object, ByVal e As System.EventArgs) Handles PropGrid.Enter
fGridEnter = True
End Sub
Private Sub PropGrid_Leave(ByVal sender As Object, ByVal e As System.EventArgs) Handles PropGrid.Leave
fGridEnter = False
End Sub
Protected Overrides Function ProcessCmdKey(ByRef msg As System.Windows.Forms.Message, ByVal keyData As System.Windows.Forms.Keys) As Boolean ' IN THIS i am having the code to move the control .
If (keyData = Keys.Down Or keyData = Keys.Up Or keyData = Keys.Left Or keyData = Keys.Right) And fGridEnter Then
PropGrid.SelectedGridItem.Select()
Return False
End If Now the problem is if i am entering caption for textbox then i use Keyboard up, down ,left ,right then Propertygrid is losing
the focus .
Textbox1.Caption = "ABC DEF " ' Here i amnot able to move the cursor using keyboard keys up, down ,left ,right
to change the text of the texbox . How to identify the things ??
|
|
|
|
|
Hello
I'd like to know a way to add a combobox on the header of a datagridview. Not in each column cell. But in the header, next to the column name. The cells of the grid should remain just as the column was a textboxcolumn.
Many thanks
|
|
|
|
|
Just build a custom user control.
Mark Brock
"We're definitely not going to make a G or a PG version of this. It's not PillowfightCraft." -- Chris Metzen
Click here to view my blog
|
|
|
|
|
Look at the example here [^]at MSDN.
Manas Bhardwaj
Please remember to rate helpful or unhelpful answers, it lets us and people reading the forums know if our answers are any good.
|
|
|
|
|
I want to develop an application in C# to access a remote desktop and show it to another computer. Like I'm the server and there's two clients, one whose desktop i'm getting, and the other client will see it. I would like to know how to start to develop such an application. Please give me some useful links or documents or anything for initial starting.
|
|
|
|
|
I might have asked this before, but I never got any good answer.
How do I implement an excel like selection?
I have a collection of many controls arranged in lines and rows, much like excel cells.
The user i supposed to select them like cells in Excel, but it just won't work.
The controls' MouseDown and MouseEnter event apparently cause the control to own the mouse and make it impossible to fire events on any other control as long as the mouse button is held down.
I also got this code on msdn, but it's utter rubbish. It will cause a single control to flicker between selected and unselected madly, it's not possible to select multiple controls and the control isn't drawn while you hold the mouse over it.
Point start;
private void pictureBox_MouseDown(object sender, MouseEventArgs e)
{
start = e.Location;
}
private void pictureBox_MouseMove(object sender, MouseEventArgs e)
{
if (e.Button == MouseButtons.Left)
{
Size selSize=new Size(e.X - start.X, e.Y - start.Y);
Rectangle selRect = new Rectangle(start, selSize);
selRect.Offset(((Control)sender).Location);
foreach (Control ctl in this.flowLayoutPanel1.Controls)
{
if (ctl.Bounds.IntersectsWith(selRect))
{
ctl.BackColor = Color.Yellow;
}
else
{
ctl.BackColor = Color.Gray;
}
}
}
} So, does anyone have a solution or at least a hint?
Tanks a lot!
|
|
|
|
|
Why is your mouse move firing for movement only in a picture box ? This code looks pretty logical to me.
Christian Graus
Driven to the arms of OSX by Vista.
"! i don't exactly like or do programming and it only gives me a headache." - spotted in VB forums.
I can do things with my brain that I can't even google. I can flex the front part of my brain instantly anytime I want. It can be exhausting and it even causes me vision problems for some reason. - CaptainSeeSharp
|
|
|
|
|
for first time i want to distribute a software with database in c#
in my software i have a datagridview that linked to a database and saved the changes
if i want create a setup project for distribution this software whether this database
with all of it's data copied to my project or not ?
|
|
|
|
|
Well, the real question is, what database do you use ? An Access DB can possibly be just distributed, but a SQL Server DB needs SQL Server to be installed, a connection string configured, etc.
Christian Graus
Driven to the arms of OSX by Vista.
"! i don't exactly like or do programming and it only gives me a headache." - spotted in VB forums.
I can do things with my brain that I can't even google. I can flex the front part of my brain instantly anytime I want. It can be exhausting and it even causes me vision problems for some reason. - CaptainSeeSharp
|
|
|
|
|
Dear christian
Thanks for your answer
Now i have a sql DB that connected to my C# program and have app.config file for DB connection
Whether if i create a setup project from my software and install it on another computer
my DB copy to new computer or not ?
|
|
|
|
|
I want to make a game draw its Board so I have been trying to pass the graphics object. I get an error saying that the
NullReferenceException
"Object reference not set to an instance of an object."
I use
In the form's Paint function
Graphics g = this.CreateGraphics();
game.DrawBoard(g);
game is a variable in the form and DrawBoard is a function of that class
public void DrawBoard(Graphics g)
{
....
}
I have also tried passing the PaintEventArgs e with the same result
It works if I make the function belong to the form but that is not what I want to do
I vaguely remember from C++ that I might need to use handles but I have not been able to find a solution.
Can anybody help?
Alan
|
|
|
|
|
Chances are your game variable isn't instantiated
Between the idea
And the reality
Between the motion
And the act
Falls the Shadow
|
|
|
|
|
Thanks everybody.
I had instantiated game in the Form load function but that must have ben too late.
I understood the debugger to be telling me that the Graphics object was Null. I never thought of the game object being Null
Finally, Why is CreateGraphics() wrong? It's use is in all the "how to do it pages on Google" I only vaguely knew about the possibility of using e.Graphics from using C++
Alan
|
|
|
|
|
Hi,
Member 950420 wrote: I understood the debugger to be telling me that the Graphics object was Null
The exception provides line information when available (normally so while debugging); and of course you have set your Visual Studio editor to always show line numbers (menu Tools/Options/TextEditor/AllLanguages:display line numbers), so you immediately can tell which line went wrong.
Member 950420 wrote: Why is CreateGraphics() wrong?
CreateGraphics() creates a new, large, complex object, whereas the one in PaintEventArgs is already there. And the one you got from CreateGraphics() needs to be Dispose()d of, otherwise you will run into delayed memory collection situations; anyhow it will slow down your app in case you have frequent repaints (e.g. when animating something).
Member 950420 wrote: how to do it pages on Google
Whatever you find on the Internet may or may not be correct; lots of examples are incorrect, i.e. they seem to function but contain fundamental flaws that will show under some circumstances. Read a serious book on the topic of interest, read some top-notch articles, and read the documentation, then judge everything you encounter for yourself.
Luc Pattyn [Forum Guidelines] [My Articles]
DISCLAIMER: this message may have been modified by others; it may no longer reflect what I intended, and may contain bad advice; use at your own risk and with extreme care.
|
|
|
|
|
Member 950420 wrote: Graphics g = this.CreateGraphics();
This is wrong. Never do it. Instead, handle the paint event, and use the graphics object passed in to that. Otherwise, if your form is obscured and then shown again, it will not redraw itself.
Member 950420 wrote: I have also tried passing the PaintEventArgs e with the same result
Yes, that is the ONLY way to do it, unless you're drawing rubber bands or other things you want to lose easily by calling Invalidate().
Member 950420 wrote: NullReferenceException
"Object reference not set to an instance of an object."
and, as someone already said, this ALWAYS means an object is null. You should learn to use the debugger, then you'd be able to work out which objects are not initiated, by stepping through the code.
Christian Graus
Driven to the arms of OSX by Vista.
"! i don't exactly like or do programming and it only gives me a headache." - spotted in VB forums.
I can do things with my brain that I can't even google. I can flex the front part of my brain instantly anytime I want. It can be exhausting and it even causes me vision problems for some reason. - CaptainSeeSharp
|
|
|
|
|
Hi,
don't use CreateGraphics except for very special circumstances; use the Graphics that is inside PaintEventArgs instead.
chances are the Paint event fires before your game has been fully initialized, so add a null test on game inside the Paint handler.
Luc Pattyn [Forum Guidelines] [My Articles]
DISCLAIMER: this message may have been modified by others; it may no longer reflect what I intended, and may contain bad advice; use at your own risk and with extreme care.
|
|
|
|