|
Handle the KeyDown event and set KeyEventArgs.Handled = true
|
|
|
|
|
In my Windows Forms application I have a listbox on the form. This is a multiple selection list box.
I can use SelectedIndices property to get the indices of all the selected items.
However, given an index number, is there a simple way to tell if the item is selected or not? Right now I search the SelectedIndices to see if the index is there. I wonder if there is a method call to tell me directly if an item is selected or not. I tried to find that but couldn't.
Thanks!
|
|
|
|
|
Hi,
you could try listBox.Items.Contains(...)
Luc Pattyn
I only read code that is properly indented, and rendered in a non-proportional font; hint: use PRE tags in forum messages
|
|
|
|
|
|
|
it should be listBox.SelectedIndices.Contains(...)
listBox.Items.Contains(...) will be true for all items.
|
|
|
|
|
Hello,
I am using propertyGrid window to display name and its value. I allow the user to enter value and if he enters a wrong value (there is a seperate code to validate), then I am supposed to display the user entered text value in red color (text in red color) or the back ground color of that particular cell alone (not the entire propertyGrid window) in red color. Is this posssible using PropertyGrid?
I can understand that the color of entire propertyGrid can be changed, but I am looking for changing single cell's either the text color or the background color of the particular cell to red.
Thanks in advance
|
|
|
|
|
The ProeprtyGrid cannot change the color of individual cells. How each cell is rendered, including color, is left up to the UITypeEditor for each property. You'd have to create a new UITypeEditor for each of the properties that you want to be able to render in a different color.
Documentation on User Interface Type Editors[^].
|
|
|
|
|
I tried using UITypeEditor which allows me to paint the cell, but it also displays a small recangular box in the cell, which makes my display look ugly. Can you tell me how to get rid of this small rectangle?
The rectangular box appears as soon as I override the following function of UIEditorType
public override bool GetPaintValueSupported(ITypeDescriptorContext context)
{
//Set to true to implement the PaintValue method
return true;
}
I tried clearing the cell in PaintValue method but that did not work
public override void PaintValue(PaintValueEventArgs e)
{
base.PaintValue(e);
Region reg = new Region(new Rectangle(e.Bounds.X , e.Bounds.Y, e.Bounds.Width+10 , e.Bounds.Height));
Region tempReg = e.Graphics.Clip;
e.Graphics.Clip = reg;
// Tried to clear the entire cell with white color but still the small rectangle appears
e.Graphics.Clear(Color.White);
e.Graphics.Clip = tempReg;
// Fill region also did not work
//e.Graphics.FillRegion(Brushes.Red, reg);
}
}
|
|
|
|
|
Since I can't see the "small rectangle" you're talking about, no I can't tell you how to get rid of it.
Perhaps a screen shot would help??
|
|
|
|
|
I m trying to click mouse automatically using code in some specific location for this i m using following code but its not working
[System.Runtime.InteropServices.DllImport("user32.dll")]
public static extern void mouse_event(int dwFlags, int dx, int dy, int cButtons, int dwExtraInfo);
public const int MOUSEEVENTF_LEFTDOWN = 0x02;
public const int MOUSEEVENTF_LEFTUP = 0x04;
public const int MOUSEEVENTF_RIGHTDOWN = 0x08;
public const int MOUSEEVENTF_RIGHTUP = 0x10;
public void MouseClick()
{
int x = 100;
int y = 100;
mouse_event(MOUSEEVENTF_LEFTDOWN, x, y, 0, 0);
mouse_event(MOUSEEVENTF_LEFTUP, x, y, 0, 0);
}
Plz Help me
To move cursor i m using Cursor.Position = new Point((int)10, (int)10); thats working fine
Plz help
|
|
|
|
|
|
shaina2231 wrote: OK the Problem IS SOlved
And how exactly did you solve the problem?
I'm interested because I'm working on same thing.
Lukas
|
|
|
|
|
Hi,
I'm using the following user32 functions:
- SetCursorPos() to move the mouse
- SendInput() to give a MOUSEEVENTF_LEFTDOWN and MOUSEEVENTF_LEFTUP
IIRC the x,y parameters of mouse_event describe a relative mouse movement, so I keep them at zero.
Here are my P/Invoke prototypes:
[DllImport("user32.dll", CallingConvention=CallingConvention.StdCall, SetLastError=true)]
public static extern IntPtr SendInput(int count, ref INPUT2 input, int size);
[DllImport("user32.dll", CallingConvention = CallingConvention.StdCall, SetLastError = true)]
public static extern IntPtr SetCursorPos(int x, int y);
public struct MOUSEINPUT {
public int dx;
public int dy;
public int mouseData;
public int dwFlags;
public int time;
public IntPtr dwExtraInfo;
}
public struct INPUT2 {
public uint type1;
public MOUSEINPUT mi1;
public uint type2;
public MOUSEINPUT mi2;
}
Luc Pattyn
I only read code that is properly indented, and rendered in a non-proportional font; hint: use PRE tags in forum messages
|
|
|
|
|
Hi,
Kindly help me, i took textbox from one of my other project into my current project but whenevr i click on Form Design its showing me this errors:
The variable TextBox1 is either undeclared or was never assigned
Plzzz help me...
Thank you
|
|
|
|
|
mirzamujib wrote: The variable TextBox1 is either undeclared or was never assigned
That's a fairly clear error message. Somewher in your copying you have omitted an allocation or reference so the main form does not have a variable called TextBox1. Take a look at the form and also the code behind to see which parts are missing. You would probably have found it simpler to add a new text box from scratch rather than doing it this way.
|
|
|
|
|
|
Delete the textbox and copy it again. Sometimes, Visual Studio suffers from selective amnesia in that it copies only a part of the code and leaves the rest.
|
|
|
|
|
Hi,
Kindly help me, i took textbox from one of my other project into my current project but whenevr i click on Form Design its showing me this errors:
The variable TextBox1 is either undeclared or was never assigned in vb.net
Plzzz help me...
Thank you
|
|
|
|
|
Hi,
What are the different ways to run a exe file auto in WindowsXP? or we have to just create a autorun.inf file.
|
|
|
|
|
On my form I have 4 controls that span the width of a form. The controls each take up ~1/4 of the available vertical space and are stacked such that the vertical space is almost completely used.
I'm having trouble getting the controls to correctly resize vertically when I resize the form. I want to maintain the same layout as now, but if I anchor both the Top and Bottom then the upper-left corner of each control is fixed, so they overlap when I resize.
How can I allow the "anchor" point to slide proportionally to the resize and maintain the same aspect?
Thanks
modified 12-Jul-20 21:01pm.
|
|
|
|
|
Today I discovered TableLayoutPanel!
modified 12-Jul-20 21:01pm.
|
|
|
|
|
Hi
I am developing application where i want to use some APS fonts which r=are installed in machine.
I am having error while i select one of APS font in font dialog box. The error says it is not a true type font .
But when i check the font in font folder of control panel there it says its a true type font.
My application will not work with out this font selection .
Please help me.
|
|
|
|
|
I can usually muddle my way through creating a regular expression but this one has me stumped (even with Expresso). I need to search through the contents of a text box and find each word in an HTML doc, but avoid the text within the tags. I have a Regex that works fine in a plain text file, but not in a doc with tags.
Example: <li>List Item</li>
I'd want to find "List" and "Item" but not "li" or "/li"
If anyone has a Regex pattern that does this I'd love to see it, with thanks.
|
|
|
|
|
Alan, try this. The code originally came from the netSpell library, so i'm not 100% it works correctly...
Private _htmlRegex As Regex = New Regex("</[c-g\d]+>|</[i-o\d]+>|</[a\d]+>|</[q-z\d]+>|<[cg]+[^>]*>|<[i-o]+[^>]*>|<[q-z]+[^>]*>|<[a]+[^>]*>|<(\[^\]*\|'[^']*'|[^'\>])*>", RegexOptions.IgnoreCase Or RegexOptions.Compiled)
"An eye for an eye only ends up making the whole world blind"
|
|
|
|