|
I'm working with a datagridview in Visual C# and one of the properties of this control keeps getting reset whenever I edit the GUI.
The following line appears in the source code:
//
this.dataGridView1.AutoGenerateColumns = false;
//
I want this property to be true however if I manually change it in the source it gets changed back to false whenever I edit the GUI. I didn't see this property listed in the properties box for the DataGridView control so I can't figure out how to permanently modify this value. Can anyone let me know where I should be looking?
Thanks in advance.
|
|
|
|
|
The AutoGenerateColumns property gets added when you assign a DataSource to the DataGridView in the Properties Window. It doesn't stop the columns being generated though, at least not on my system when I just tested it.
The MSDN page for the property here[^], has an example showing where and how to set it. (Sets it to false)
If I search for the property in the Index from within the VS IDE, I get a different page with a different example. (Sets it to true)
So take your pick. You really should search MSDN at the very least before asking here, and preferably Google as well. Your question has been hanging about for nearly 24 hours when you could have had the solution almost instantly.
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.”
|
|
|
|
|
Hi all,
I'm trying to track down why my report takes so long to load the first time but subsequent loads are quite quick. I'm setting the datasource of the report to a dataset, but that's done every time. However, in stepping through the code, I've found that the first time I run this segment of code, it takes a few seconds for the data source to get set. But on subsequent runs it takes no longer than any other command. Any ideas? I've posted the relevant part of the code below.
If ds.Tables(0).Rows.Count > 0 Then
AddImageColumn(ds.Tables(0), "ClientPic")
Dim myFilename As String
myFilename = myG.AppLocation & "\" & myDB.DoExecScalarQuery("select picture from personal")
If File.Exists(myG.AppLocation & "\ClientDocs\" & myG.Patient & "_clientimage.jpg") Then
If File.Exists(myFilename) Then
LoadImage(ds.Tables(0).Rows(0), "ClientPic", myFilename)
End If
ds.WriteXml(applocation & "\personal.xml")
ds.WriteXmlSchema(myG.AppLocation & "\personal.xsd")
'Dim rptPersonal As New crptPersonalInfo ' now declared in main
rptPersonal.SetDataSource(ds) ' THIS IS THE LINE THAT'S SLOW THE FIRST TIME
' Dim rptPersonalViewer As New frmReportViewer ' now declared in main
rptPersonalViewer.cr.ReportSource = rptPersonal
rptPersonalViewer.ShowDialog()
Else
MsgBox("Please check your personal information. It appears some of it may be missing.",
MsgBoxStyle.OkOnly, "No Data For Report")
End If
Catch ex As Exception
Dim myE As New EventLogging.EventLogging
myE.StoreEvent("frmRptParams.RunReport", "Error running report", ex.Message & vbCrLf & vbCrLf & "SQL was: " & strPersonalInfo)
myE = Nothing
MsgBox("There was a problem gathering data for the Personal Info report. If the problem persists please contact customer service.", MsgBoxStyle.Exclamation, "Report Not Run")
Finally
da = Nothing
ds = Nothing
End Try
Denise "Hypermommy" Duggan
|
|
|
|
|
ActiveElement property of Document class of WebBrowser always return BODY Element. if you know why it does send me answer. otherwise please send me a code snippet which it works well.
Thanks
|
|
|
|
|
(using .net 3.5)
I'm trying to get a list of groups that a given user is a member of. I'm trying to use the following code (using the System.DirectoryServices.AccountManagement namespace):
PrincipalContext context = new PrincipalContext(ContextType.Domain, "myDomain");
UserPrincipal userPrincipal = UserPrincipal.FindByIdentity(context, IdentityType.SamAccountName, this.UserID);
PrincipalSearchResult<Principal> groups = userPrincipal.GetGroups(context);
It's throwing an exception on the 2nd line of code, saying that the userID or password is invalid.
I know for a fact that the userID I'm using exists on the domain. What am I doing wrong?
EDIT (SOLUTION) =====================
I had to change the first line to this:
PrincipalContext context = new PrincipalContext(ContextType.Domain, "myDomain", userID, password);
"Why don't you tie a kerosene-soaked rag around your ankles so the ants won't climb up and eat your candy ass..." - Dale Earnhardt, 1997 ----- "...the staggering layers of obscenity in your statement make it a work of art on so many levels." - Jason Jystad, 10/26/2001
|
|
|
|
|
In a .aspx page I have taken a detailsview and in the template field I have taken a btton.
I want the code that if I click on the button the data part of the detailsview will change in a textbox whrer I can change the data and can update it on the database
|
|
|
|
|
|
I've noted with interest that there seems to be a lack of open source tools for .NET test coverage analysis. I'm pretty comfortable with .NET, but off the top of my head, I can't figure out how someone could do it without making their own version of the runtime or tampering with the IL emitted when code is compiled (which sounds like either great resume material, insanity, or possibly both).
I'm just kind of curious, but I'm not sure even how this sort of thing is typically done.
|
|
|
|
|
Easier than tampering with the IL is tampering with the source code. I used to do formal unit testing and I don't know if it's a formal term or not but we called it "instrumenting a file" and it's a bit of tedium that automated processes are made for. The trick is to modify the source without actually changing the control flow of the code. Take the following function:
private void MyMethod()
{
int x = SomeFunction();
int y = SomeOtherFunction();
if (x > y)
{
}
else
{
}
} There are 5 bits of code you need to ensure are executed, so for each place insert a boolean:
static bool flag1 = false;
static bool flag2 = false;
static bool flag3 = false;
static bool flag4 = false;
static bool flag5 = false;
private void MyMethod()
{
flag1 = true;
int x = SomeFunction();
flag2 = true;
int y = SomeOtherFunction();
flag3 = true;
if (x > y)
{
flag4 = true;
}
else
{
flag5 = true;
}
} Then you can run your test cases and check the value of your bools to make sure that all of your code was executed. Note that the control flow of the code hasn't changed, we've just added stuff to verify that all bits are executed. The difficulty comes in when you start taking into account the endless variations of source code. For example:
private void MyMethod()
{
int x = SomeFunction();
int y = SomeOtherFunction();
if (x > y)
{
}
} looks easier, but you still need to insert the else to the if when you instrument that method to prove that the if statement can be failed. If the if can't be failed then it's unnecessary (dead code) and shouldn't be there.
The biggest PITA to instrument (and test) is full MCDC coverage (google it). Take the following sample:
private void MyMethod(bool a, bool b)
{
if (a || b)
{
}
} There's a multi-conditional if statement there, and you need to prove that both conditions are necessary. Why? Well, suppose hypothetically that a is always true . Then the statement will always evaluate to true and there's no point in checking either a or b . The same thing happens if b is always true, so you need to instrument that in such a way to prove that both a and b can be false independently of each other. To verify full coverage that one statement turns into something like this:
static bool flag1 = false;
static bool flag2 = false;
static bool flag3 = false;
static bool flag4 = false;
private void MyMethod(bool a, bool b)
{
flag1 = true;
if (a && !b)
{
flag2 = true;
}
else
{
if (b)
{
flag3 = true;
}
else
{
flag4 = true;
}
}
} and that 's just a simple multi-conditioned statement! Try figuring out how to break this down:
if (a || ((b && c) || d) || (x > 2))
{
} Hopefully you either don't care about such things or you can afford to buy a tool to do this for you. Trust me, it will drive you crazy.
|
|
|
|
|
The .NET Framework has a profiling API available for just such a thing. Here's a nice introductory article.[^].
"we must lose precision to make significant statements about complex systems."
-deKorvin on uncertainty
|
|
|
|
|
The CLR profiler allows you to rewrite IL at JIT time. That would be one place to put instrumentation code to track what code is getting executed.
|
|
|
|
|
I have a set of objects that I want to do some processing on prior to serializing and after deserializing,using wcf for coms.
The code is included below. I understand that I should change OnDeserializing to OnDeserialized, and have, but neither get called.
If I put a break in the OnSerializing method, the debugger stops there. If I put a break in the OnDeserializing method, the debugger never stops there. It is also clear from the errors I am getting that the re-hydration has not happened.
I am following the same pattern for both the pre and post calls. The compiler is happy with them, and they look like they match the patterns in the online doc.
Any ideas? This is also posted on MSDN with no help forthcoming.
hury Plz snd code and dollars
TIA
[OnSerializing ()]
internal void OnSerializingMethod(StreamingContext context)
{
long temp = 0;
if (context.State != StreamingContextStates .Clone)
{
Dehydrate (null , ref temp);
}
}
[OnDeserializing ()]
internal void OnDeserializingMethod(StreamingContext context)
{
if (context.State != StreamingContextStates .Clone)
{
Rehydrate (0);
}
}
Silver member by constant and unflinching longevity.
|
|
|
|
|
Because of WCF generate proxy for DataContract with [System.Diagnostics.DebuggerStepThroughAttribute()].
|
|
|
|
|
Hi,
I have developed a smart client desktop application using SCSF.
It has an MDI and MDI child forms opens over it(It is similar to windows menu based application using MDI) .
The problem is that the MDI child forms (i.e. the views) take a few seconds to open and load.
Is there any way of minimising the time it takes.
The forms are having simple text boxes and labels and grids(which has two columns and is not populated during load)
I call a webservice at form load and have tried to comment the service call; Even then it takes the same time so I have ruled out the possibility of service delay.
Nothing else is done at the form load except the form is rendered
All MDI child forms(views) are taking the same time.
The application is stand alone not run remotely or checks for any updates on any server.
I dont have knowledge of SCSF internals, and how SCSF does all the handling of smart parts etc.
May be it might be tuned up to load the views faster or there is some way to make the CAB work faster which I am unaware of.
Could not find the forum related to SCSF so posting it here, please suggest in case you have knowledge of SCSF message board in code project.
Thanks in advance.
Sakshi
|
|
|
|
|
SCSF uses reflection very heavily. Because of this reason performance is hit when trying to do what would seem the simplest of things. It is a very heavy framework and unless you really need it and are concerned about performance I would suggest an alternative.
|
|
|
|
|
Dear all, upon developing data entry project I've faced a problem and I still can't figure out the solution.
Simplifying the matter, lets say that the the user enters the ID value and should get the decription in another column (DataGridViewTextbox) in the same datagridview. The description column should get updated immediately after the value of the ID column is changed.
The scenario is very close to classical master/detail form except that the detail should be displayed into the same control.
I had particullar success when bound the datagridview control to dataset relation, but the form didn't work well when inserting new rows.
Can you provide me with brief advice or a link?
Kind regards,
|
|
|
|
|
|
Thank you very much for your reply!
I will take a look.
Anyway I will try to clarify myself by pseudo-code.
Consider DB with two tables:
table "payments" with the following structure:
"p_id" int,
"price" int,
"empl_id" int
and "employees":
"empl_id" int,
"empl_name" varchar /* this I want to get later */
It is not difficult to bind the DataGridView control to the "payments" table.
In the form I define the following columns (binding them to corresponding columns in data source):
datagridview.Columns("pay_id").DataPropertyName = "payments"."p_id"
datagridview.Columns("price").DataPropertyName = "payments"."price"
datagridview.Columns("empl_id").DataPropertyName = "payments"."empl_id"
And here is it, I want to have a column which displays the employee's name taking it from table "employees". Something like:
datagridview.Columns("empl_name").DataPropertyName = "employees"."empl_name"
This column should refresh every time the user changes the value of datagridview.Columns("empl_id") providing him with the name of the employee.
But there is no way (at least I don't know how) to define another data source for DataGridViewTextBox column. May be I need to populate manually the cell with the employee's name fetching it from dataset relation.
Previously I hadn't used .NET for data entry forms which is my primary fields so I am not very certain about its classes and their properties.
Thanks and regards,
|
|
|
|
|
you can use DataGridViewComboBox column instead of DataGridViewTextBoxColumn to show employee's name.
Example:
datagridview.Columns("empl_name").DisplayMember="empl_name"
datagridview.Columns("empl_name").ValueMember ="empl_id"
datagridview.Columns("empl_name").DataSource ="employees"
datagridview.Columns("empl_name").DataPropertyName="payments"."p_id"
datagridview.Columns("empl_name").DisplayStyle=Nothing
|
|
|
|
|
Hi,
how to pass a "IS NOT NULL" to an OleDbParameter?
I know how to do "IS NULL":
parameter = new OleDbParameter(myField, Convert.DBNull);
Any Help would be great...
Thank's
:k:
|
|
|
|
|
|
You can pass in an actual Null value for the parameter using your code, but this doesn't mean you're passing "IS NULL" or "IS NOT NULL". These aren't values, they're conditions, presumably your stored procedure or query would then use IS NULL or IS NOT NULL to check whether or not the value you passed in was or was not a Null.
|
|
|
|
|
How do .net framework relates to ajax technology.
|
|
|
|
|
sapna sangole wrote: How do .net framework relates to ajax technology.
They are both code.
Please clarify what you are asking - are you asking how do you implement AJAX in the .NET framework, or are you asking what AJAX is, and how it differs from the .NET framework?
"WPF has many lovers. It's a veritable porn star!" - Josh Smith As Braveheart once said, "You can take our freedom but you'll never take our Hobnobs!" - Martin Hughes.
My blog | My articles | MoXAML PowerToys | Onyx
|
|
|
|
|
You can use AJAX with .Net framework in 2 ways
1. Use asynchronous Javascript method call to find server function and write everything by you only by you.
2. Or Install free Microsoft AJAX Framework and take advantage of AJAX Control Toolkit.
Education is not a way to escape poverty — it is a way of fighting it.
|
|
|
|