|
Hello all!
I am new to c#.net 2.0. I am using a datagridview and would like to update the current(selected) row in it. Can anyone provide some help. I read about datatable, datarow. Yet, I found no property that returns the index that points to the current row.
Thanks All,
Tan the man
Tan the man
|
|
|
|
|
|
Hi,
How to delete rows from a DataTable completely from the memory.
Regards,
Subbu
|
|
|
|
|
Do you want to remove them from the table, or the data source ? If just the table, just delete them.
Christian Graus - Microsoft MVP - C++
|
|
|
|
|
Hi,
I am writing an application containing a treeview.
The requirements state that the treeview should have checkboxes to help multi-selection. However, the checkboxes on the treeview do not look nice at all . The checkbox outline is thick and looks rather silly. How can I change this? Is it possible to make the outline thinner?
Any help is much appreciated
Regards
Peter
|
|
|
|
|
First, there are some free controls on Codeproject that do this already. Check them out if you haven't yet.
Secondly, you can try drawing the checkbox using either the system drawing (which is unthemed):
System.Windows.Forms.ControlPaint.DrawCheckBox
Or if you're using .NET 2.0, you can try drawing the system themed checkbox which looks a lot nicer:
using System.Windows.Forms.VisualStyles;
...
if(VisualStyleInformation.IsSupportedByOS == true)
{
VisualStyleRenderer renderer = new VisualStyleRenderer(VisualStyleElement.Button.CheckBox.CheckedNormal);
renderer.DrawBackground(myGraphicsSurface, rectangleToDrawIn);
}
Tech, life, family, faith: Give me a visit.
I'm currently blogging about: Little House on the Flickr
Judah Himango
|
|
|
|
|
Thanks for your reply
I'm using .NET 1.1 so will try the System.Windows.Forms.ControlPaint.DrawCheckBox approach. I'll also have a look for the controls you talked about too.
|
|
|
|
|
I have two simple dlls and one main application.
first dll is:
namespace baseDll{
public class baseClass{}
}
the second dll is:
using baseDll;
namespace childClass:baseClass{
public class childClass{}
}
//with a correct reference to base dll
and the main application is:
public static void Main(string[] args){
Assembly a1 = Assembly.LoadFile(@"C:\childDll.dll");
Assembly a2 = Assembly.LoadFile(@"C:\baseDll.dll");
System.Type t2 = a2.GetType("baseDll.baseClass");
System.Type t1 = a1.GetType("childDll.childClass");
if (t2 != null){
Console.WriteLine(t2.FullName);
}
if (t1 != null){
Console.WriteLine(t1.FullName);
}
}
It prints only t2, while t1 has an undifined value..
What's wrong, and what can be a workaround to this?
-- modified at 14:45 Thursday 12th January, 2006
Now I tried to run it with mono, and it works ok..
Moreover when I use Assembly.LoadFrom instead of Assembly.LoadFile it works fine...
|
|
|
|
|
Have a look at the LoadFile documentation (I only have a german link at hand but you should easily find it on MSDN). It says something like that i should only be used to load and check assemblies with same identities on different paths and that i doesn't resolve references like LoadFrom does.
The workaround is clear: Use LoadFrom
|
|
|
|
|
thanx!
Can you please elaborate though on what is "same identities"?
If I use Assembly.LoadFrom it doesn't have the same identity? (what is this identity of an assembly...)
|
|
|
|
|
Have a look here[^].
I'm not really an expert on this topic, but I think if you just copy one assembly to another path than those two assemblies have the same identity.
|
|
|
|
|
Hi,
I want to develop a web service, that has to access a local file. Can I use relative path, like ../data/filename.dat or Application.Startup + "//data//filename.dat", to navigate to the file?
Thanks a lot!
Alan Shen
MCAD for .NET Version
^~^~^~^~^~^~^~^~^~^~^
Great idea is the beginging of success!
|
|
|
|
|
Use HttpServerUtility.MapPath() method.
From the web service, you have the access to the "Server " object. You can simply write Server.MapPath() and pass in a relative path to get the full physical path back.
Example: Server.MapPath( "bin/YourWebService.DLL" ) returns the full physical path of YourWebService.DLL.
For more information, see the MSDN help on HttpServerUtility.MapPath() .
Koushik Biswas
|
|
|
|
|
Hi,
My project has several tab pages. When tabCoS is clicked on (which contains a datatable/datagrid), if a row was previously selected, I like to select it again.
private void tabControl1_SelectedIndexChanged(object sender, System.EventArgs e)<br />
{<br />
if (this.tabControl1.SelectedTab == tabCoS)<br />
{<br />
if (rowState == "unselect"){this.dg.Select(row);}<br />
}<br />
}
This doesn't work. Although when I throw a messagebox in before this.dg.Select(row); , after I hit OK, it works fine and the row is selected. This type of thing has happened before (commands don't work unless I put a messagebox in and click ok). Any idea why???
Thanks!
Mel
|
|
|
|
|
Are you sure your datagrid shows selection when it doesn't have focus?
It may be that the tab control maintains focus when you switch between tabs. The return from MessageBox may be handled in a different way (i.e. set focus to first tab stop).
Try replacing
{this.dg.Select(row);}
With
{this.dg.Select(row);this.dg.Focus();}
|
|
|
|
|
ok i'm a newbie with database and i'm just making some exercise to learn.
I'm learning also with ADO.NET book.
But i want to understend by you this concept.
If i query a database and i get the values into a DataSet object, then if i have to insert a new row o delete or update one just i do it on my DataSet then at the last make something to apdate again the database or all these operation need to do directly on the original database then empty the DataSet and update it again?
Thanks for help!
|
|
|
|
|
Hello,
I' m also a newbie (2weeks now) and did also some excersises on a database.
Are you using an SQL database ?
I do the updates on the dataset. When you generate the dataadapter and oledbconnection for sql, visual studio generates automatic update command for the sql. Is that what you are trying ?
Best regards Harry
|
|
|
|
|
yes, but my database is Access
|
|
|
|
|
Hi sasuko and harry, would you like some light reading[^]?? :P it's a good article.
You should be able to understand how to use ADO.NET the easy way, because believe me, it's difficult.
daniero
|
|
|
|
|
So here is my issue. I am communicating to UPS via there rate web service. I am retreiving the shipping options and costs and adding listItems to a radiogrouplist control (code below). I then have a button control that fires and event to take the value of the selectedItem and pass that through a calculateShipping() function...which updates order and cost. My problem is that when I fire the button event no value is able to be retrieved. I have tried retreiving the item.Text and nothing comes through there either. Here is the unusual point. If I manually add an item before the programmatic items are added then I can get the manually added items value..but none other. Am I building the line items incorrectly? Is this an issue with the control. PLEASE HELP!
C#
Code for programmatically adding listItems to the RadioButtonList control (rbUPS):
if (us.ServiceCode == ShipCode) {
ServiceName = ServiceName.Replace("®","");
odb.UpdateTempOrderShipping (cid,
ServiceName,
us.ServiceCharge * shipments *
decimal.Parse (ConfigurationSettings.AppSettings ["ShippingMultiplier"]));
this.rbUPS.Items.Add(new ListItem( ServiceName + " ($" + Math.Round(ShipCost,2) + ")", us.ServiceCode));
ListItem selectListItem = rbUPS.Items.FindByValue(ShipCode);
selectListItem.Selected = true;
}
else
{
this.rbUPS.Items.Add(new ListItem( ServiceName + " ($" + Math.Round(ShipCost,2) + ")", us.ServiceCode));
}
Code for the button control (updateShippingBtn):
public void UpdateShippingBtn_Click(object sender, System.EventArgs e)
{
if (rbUPS.SelectedIndex > -1)
{
string upsCode = rbUPS.SelectedValue;
//Response.Redirect("test.aspx?test=" + upsCode);
Session["ShipCode"] = upsCode;
}
else
{
Session["ShipCode"] = "03"; //UPS Ground Default
}
step.Value = "2";
headlineCheckoutStep.Text = titleCheckoutStep.Text = "Confirm Your Order";
checkoutStep.ImageUrl = ConfigurationSettings.AppSettings ["SystemImagePath"] + "steptwo.gif";
stepTwoPanel.Visible = true;
stepThreePanel.Visible = false;
CustomersDB cdb = new CustomersDB();
string cid = cdb.GetCustomerID();
calculateShipping (cid);
outputStepTwo (cid);
}
WHAT AM I DOING WRONG?
|
|
|
|
|
I have a database with hundreds of stored procedures and I am sure that many of them are never called.
I know how to find dependencies within the database using the system tables but that doesn't tell me how many are called from the Visual Studio project (and if so where)
I am mulling 2 different approaches but am not really sure how to go about either...
1) FXCop somehow manages to find all the strings in a compiled assembly and tell you where abouts in the project they are. I guess this solution would be optimal as I guess it would exclude comments and such like which may slightly mess up the results. I also guess writing something like that would be pretty time consuming so would be grateful if anyone has any sample code or links to articles doing this sort of thing.
2) I also considered trying to programatically automate the Visual Studio "Find" option and found it very straightforward to get the results to appear in the FindResults Window but no obvious way to get the results into a variable to manipulate.
All ideas welcome on either approach (or if you know if something like this already exists please let me know also!)
|
|
|
|
|
Hi all, i'm trying to access files on a networked dirve using the UNC name "\\myServer\d$".
Unfortunately if i dont have a drive mapped when i try to find files on the server i get an IOException saying that the directory doesn't exist.
I found some useful comments at the bottom of an article talking about using WHScript's MapNetworkDrive method. This sounds good but i can't get it to work. Here's my code which is only slightly different from the comment on the article.
public void InvokeComMember(string member, params object[] param)
{
Type type;
Object o;
try
{
type = Type.GetTypeFromProgID("WScript.Network");
o = Activator.CreateInstance(type);
type.InvokeMember(member, BindingFlags.InvokeMethod, null, o, param);
}
catch{}
finally
{
type = null;
o = null;
}
}
The paramaters being passed in are...
InvokeComMember("MapNetworkDrive", @"\\" + serverName + @"\d$", "", false, userName, password);
serverName , userName and password are all strings that i've double checked are correct.
The exception i get is...
System.Exception: Invoke Com Error ---> System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation. ---> System.IO.FileNotFoundException: The network name cannot be found.
When i type the same \\"serverName"\d$ into the run window i get a connection fine so i know the serverName variable is correct.
Anyone know either...
1. What i'm doing wrong with this or
2. Another way of getting at the files on the UNC'd server.
Cheers
Kev
-- modified at 8:49 Thursday 12th January, 2006
|
|
|
|
|
|
Yeah i found that. The example i gave was from the comments section of that article. The class used in the article requires you to provide a drive letter. The ideas used in the comments section at the bottom of the article givesa a way of doing it without using a drive letter but i can't get it to work.
All i want to do is access some files using a unc name and the relevant login cridentials.
Cheers
Kev
|
|
|
|
|
Hi,
Why doesn't this unselect?
(On MouseUp)
row = HitInfo.Row;<br />
if (dg.IsSelected(row)){this.dg.UnSelect(row);}<br />
else {this.dg.Select(row);}
I threw a messagebox in before this.dg.UnSelect(row); and I can't even get it to come up.
Thanks for any help!
Mel
|
|
|
|