|
I've searched this forum and just simply can't find an answer already written out.
I am creating a user control using the designer. The control only paints stuff like lines and colors within its bounds using OnPaint and OnPaintBackground.
Now, I need to respond to mouse clicks, yet I cannot get the control to respond to any mouse clicks.
if I do Capture = true, then it will listen to 1 single event, and then Capture is lost and i cannot click again. When I do capture, the mouse cursor turns into an hourglass anyway, which I dont want.
How does one listen to events of a UserControl??? It seems this should work simply... but it does not. I am adding this control into a Table control which is in a form. There really isn't much more to it than that.
I have a deadline and I'm just stumped on something that should be so ridiculously simple... yet its not.
Here is the basic class I'm writing, its just a UserControl created from the visual designer. I've got breakpoints on all those mouse events and NOT ONE fires.
PLEASE HELP!
public partial class HomeHeader : UserControl
{
public HomeHeader()
{
InitializeComponent();
}
protected override void OnClick(EventArgs e)
{
base.OnClick(e);
}
protected override void OnMouseDoubleClick(MouseEventArgs e)
{
base.OnMouseDoubleClick(e);
}
protected override void OnMouseDown(MouseEventArgs e)
{
base.OnMouseDown(e);
}
protected override void OnMouseMove(MouseEventArgs e)
{
base.OnMouseMove(e);
}
protected override void OnMouseUp(MouseEventArgs e)
{
base.OnMouseUp(e);
}
}
|
|
|
|
|
Hi,
I have no trouble getting normal mouse events on a form holding two instances of this little UserControl1,
which holds a ListBox, a ComboBox and a Label. The Label text gets updated for the one UserControl1 instance my mouse is hovering over, as long as I'm not over one of its internal Controls (that's why I'm having the ListBox and ComboBox).
public partial class UserControl1 : UserControl {
public UserControl1() {
InitializeComponent();
}
private void log(string s) {
label1.Text=DateTime.Now.ToString("mm:ss.fff ")+s;
}
private void UserControl1_MouseMove(object sender, MouseEventArgs e) {
log("MouseMove");
}
or
public partial class UserControl1 : UserControl {
public UserControl1() {
InitializeComponent();
}
private void log(string s) {
label1.Text=DateTime.Now.ToString("mm:ss.fff ")+s;
}
protected override void OnMouseMove(MouseEventArgs e) {
log("MouseMove");
base.OnMouseMove(e);
}
}
The main difference with your code is my MouseMove handler contains real code, it does not just call base.OnMouseMove(). Instead it shows a little string in a label.
IMO base.OnMouseMove() does nothing by default, an empty UserControl simply has no functionality.
Luc Pattyn [Forum Guidelines] [Why QA sucks] [My Articles]
I only read formatted code with indentation, so please use PRE tags for code snippets.
I'm not participating in frackin' Q&A, so if you want my opinion, ask away in a real forum (or on my profile page).
|
|
|
|
|
Sigh...
Everyone ignore this thread... I am embarrassed to say that somehow i managed to not notice a large Image box in the user control designer that wasn't supposed to be there that was transparent and taking all the clicks.
everything works as it should now...
Sigh...
|
|
|
|
|
So my ListBox and ComboBox were a hint for you then.
Luc Pattyn [Forum Guidelines] [Why QA sucks] [My Articles]
I only read formatted code with indentation, so please use PRE tags for code snippets.
I'm not participating in frackin' Q&A, so if you want my opinion, ask away in a real forum (or on my profile page).
|
|
|
|
|
I have a datagridview bound to a bindingsource bound to a List<>. The datagridview is sitting on a tabpage; the bindingsource is bound to the List<> while the tabpage is not current.
Then, when the tabpage is made current, i.e., is made visible, the text that overflows a single line in the datagridview is wrapped but the rowheight is not adjusted for the second and subsequent lines of text.
On the other hand, if the bindingsource is bound while the datagridview is visible, the rowheight is set correctly.
I realize I can wait till the tabpage is current/visible to bind the bindingsource, but it just doesn't seem that should be required.
Thanks in advance.
Snerril Blackmon
|
|
|
|
|
You could try using the BindingSource.ResetBindings() when the DGV becomes visible. This will cause it to reset its data and display.
Henry Minute
Do not read medical books! You could die of a misprint. - Mark Twain
Girl: (staring) "Why do you need an icy cucumber?"
“I want to report a fraud. The government is lying to us all.”
|
|
|
|
|
Henry,
Charming solution. I had tried the BindingSource.ResetBindings()in several events but (silly me) I had never put it in the VisibleChanged event.
I appreciate you.
Sherril
|
|
|
|
|
My pleasure.
Henry Minute
Do not read medical books! You could die of a misprint. - Mark Twain
Girl: (staring) "Why do you need an icy cucumber?"
“I want to report a fraud. The government is lying to us all.”
Why do programmers often confuse Halloween and Christmas?
Because 31 Oct = 25 Dec.
|
|
|
|
|
I am using a DataGrid (yes, I know I should be using DataGridView by now!) and I want to disable cell selection. I am talking about the text in a cell getting selected when the users clicks in a cell.
I don't want this because I am using a context-menu on the DataGrid that should appear when user right-clicks on a cell, and this doesn't work when user right-clicks on a selected cell because then the Windows edit menu pops up instead.
|
|
|
|
|
You should try SelectionMode property of datagridview.
HTH
Jinal Desai - LIVE
Experience is mother of sage....
|
|
|
|
|
hi sir
i am connecting the reportviewer to dataset but i am fail.i am using following code.please help me.
using System;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;
using Microsoft.Reporting.WebForms;
using System.Data.SqlClient;
public partial class _Default : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
ReportViewer1.Visible = false;
}
protected void Button1_Click(object sender, EventArgs e)
{
}
protected void Button1_Click1(object sender, EventArgs e)
{
ReportViewer1.Visible = true;
SqlConnection con = new SqlConnection("server=DC-12\\SQLSERVER2005;uid=sa;pwd=start;database=Vikas_Data");
SqlCommand cmd = new SqlCommand();
cmd.CommandText = "seldata";
string pn = TextBox1.Text;
cmd.Parameters.AddWithValue("@pn", pn);
cmd.CommandType = CommandType.StoredProcedure;
cmd.Connection = con;
SqlDataAdapter adap = new SqlDataAdapter();
adap.SelectCommand = cmd;
DataSet ds = new DataSet ();
adap.Fill(ds, "table");
ReportViewer1.LocalReport.ReportPath = "MyFirst.rdlc";
ReportDataSource rds = new ReportDataSource();
rds.value=ds.Tables[0];
ReportViewer1.LocalReport.DataSources.Add(rds);
ReportViewer1.LocalReport.Refresh();
}
}
there is no error .but data will not be show in report viewer.
please help me .as soon as possible .what may be the issue.
|
|
|
|
|
You might want to try clearing the existing data sources first with
Me.ReportViewer1.LocalReport.DataSources.Clear()
and possibly in the form.designer.vb comment out the lines which would have been added if/when you selected the report using the ReportViewer Tasks box
'Dim ReportDataSource1 As Microsoft.Reporting.WinForms.ReportDataSource = New Microsoft.Reporting.WinForms.ReportDataSource
and
'ReportDataSource1.Value = <the original="" data="" source="">'Me.ReportViewer1.LocalReport.DataSources.Add(ReportDataSource1)
I have found that almost every problem I've had with report viewer not displaying the report was to do with data in some way or another.
Have you confirmed that your adap.fill line is actually putting some records into the dataset?
Hope this is of some help.
|
|
|
|
|
Hi there, my company's software product has a feature that allows users to generate forms from Word templates. The program auto fills some fields from the SQL database and the user can fill in other data that they desire. So we have a .dotx template that holds the design of the form, and then the user gets the .docx file to fill out when they call it from our program.
The problem we're having is that some of our users have been finding that the forms take an exceptionally long time to open up and then, once open, are so slow to respond (scroll around, etc) that they're unusable. So in my investigations so far, I've found out that the problem systems are one with lower powered CPUs (unfortunately it happens for systems above our system requirements) and the Word forms that cause the problems are ones with large amount of ActiveX style checkboxes on them. I verified that reducing the ActiveX checkboxes fixes the form loading problems.
So I have the following questions about solutions (we're using Word 2007):
1) Is there any way to configure Word, or some other settings, so that there won't be such a strain opening a Word form with lots of ActiveX checkboxes? Any way of speeding up Word's opening?
2) Using Legacy style checkboxes instead of the ActiveX ones makes the forms load fine, but it looks like the user has to double-click the checkbox and change Default Value->Checked. Is there a way to configure it so that they can simply click on the checkbox to tick it? "Legacy Forms" checkbox as a name kind of worries me (Legacy…), does that mean a future version of word at some point wouldn't load the checkboxes because they're "legacy"?
3) Yes, it became clear to me after a little bit of research into solutions that Word is not the tool for the job for forms like I'm describing. InfoPath seems to be exactly what we should have been using all along but unfortunately I wasn't involved in the decision making or development of these forms, just tasked with coming up with a solution.
I'd appreciate answers to any of these, or if anyone has any other ideas for solutions to this problem.
Thanks
|
|
|
|
|
I have written the following code in windows
---------------------------------------------
TextBox1.Text = Application.ProductName + "." + acode.Text;
System.Reflection.Assembly tempAssembly = System.Reflection.Assembly.GetExecutingAssembly();
Form frm1 = new Form();
Form frm1 = (Form)tempAssembly.CreateInstance(TextBox1.Text);
frm1.show();
---------------------------------------------
Here error is been generated,in frm1.show() line,object reference not set to an instance of the object.The TextBox1.Text contents are not
been displayed in frm1 which is the instance of Form and getting null
value
Please suggest me the solution to the error above.
Thanks
Ramesh
|
|
|
|
|
There is at least one obvious problem:
Form frm1 = new Form();
Form frm1 = (Form)tempAssembly.CreateInstance(TextBox1.Text);
The first of these two lines sets frm1 to be a new instance of a Form .
The second line then tries to change frm1 into whatever you have in TextBox1.Text , unfortunately whatever you have there cannot be found so frm1 is set to null which is why you are getting the error.
You probably do not need the first line.
If you show an example of what might be in acode.Text people might be better able to help you.
In the interim you might want to try:
Form frm1 = (Form)tempAssembly.CreateInstance(TextBox1.Text, true);
Which tells CreateInstance not to worry about the case of the parameter text, just in case your acode.Text is correct except for the case.
Henry Minute
Do not read medical books! You could die of a misprint. - Mark Twain
Girl: (staring) "Why do you need an icy cucumber?"
“I want to report a fraud. The government is lying to us all.”
|
|
|
|
|
Member 4470223 wrote: Form frm1 = new Form();
Form frm1 = ...;
that does not compile without errors, does it?
Luc Pattyn [Forum Guidelines] [Why QA sucks] [My Articles]
I only read formatted code with indentation, so please use PRE tags for code snippets.
I'm not participating in frackin' Q&A, so if you want my opinion, ask away in a real forum (or on my profile page).
|
|
|
|
|
I'm looking to design a windows form application. My idea for the interface is to have a tree view on the left of my form as a menu structure to navigate between functions and the rest of the form to display the different 'screens'.
Basically what I'm imagining is something that resembles a deck - a vertical stack of screens where only one is visible at a time, similar to a TabControl but without the actual tabs.
My first attempt involved using Panels, but I couldn't switch between the panels in the design view.
Is this sort of functionality possible? if so, any ideas would be greatly appreciated.
|
|
|
|
|
Extend a TabControl. Call it say CustomTabControl. The idea is to remove the tabs. So, you get the functionality you want. There are many articles here on how to have custom tab controls. You basically need to tweak following properties.
ItemSize = (0, 1)
SizeMode = TabSizeMode.Fixed
Appearance = TabAppearance.Buttons
|
|
|
|
|
That seems to do what I wanted. Thanks!
|
|
|
|
|
In my searching I also found a PanelManager created by Mick Doherty:
http://dotnetrix.co.uk/custom.htm[^]
It works similarly, but provides easer navigation between panels.
|
|
|
|
|
hello
dear friends i have a problem
that i have added checkbox in datagrid view its working properly but i want to select all checkboxes at a time can anyone tell me how can i do that
i have added checkbox in gridvew from gridview collection poperty
|
|
|
|
|
You might have to go through this article.
|
|
|
|
|
I think this is a windows forms. The article corresponds only to ASP.Net.
|
|
|
|
|
|
What would be the most practical Regex pattern for a whole-word-only search?
Example: Match "life" but not "life's"
|
|
|
|