|
Could you explain what exactly i have to do, i have to copy the assemblies in my runtime directory form %WINDIR%\assembly\gac and then add a reference to them thru the .NET tab and not the COM tab?
I really appreciate your help
From Greece:
Dimitris Iliopoulos
dimilio@yahoo.com
|
|
|
|
|
You'll need to copy those assemblies somewhere else to use them explicitly without the designer. Start a command prompt (cmd.exe in Windows NT-based OSes) and type:
cd %windir%\assembly\gac
dir You'll see a bunch of directories that match assembly names. You'll need to cd to each of those and then the version (should start with "11.") and copy those assemblies elsewhere, like C:\Program Files\Microsoft.NET\Office11 (recommended, where the Office10 assemblies get their own folder in that directory, which is the parent directory of the default .NET 1.1 SDK).
The important thing is that you use the primary interop assemblies whenever possible.
The way the interop assemblies are registered, however, VS.NET should've used the PIAs already. See, PIAs are typically generated by the company that produced the associated typelib and they are registered so that the typelib registry keys contain and entry that specify the PIAs associated with that typelib, so instead of creating a new typelib the old one is used.
Before you do anything, I would look at the path of the Office assemblies you've already referenced and see if the path is C:\Windows\assembly\gac\....
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
I ,finally after lot of search, found what is the problem. It's a bug in office XP and office 2003. When you have installed the english version of office and you regional settings are not the same then you cannot call some functions, especially in Excel, and you have to use InvokeVerb so you tell with what exactly Culture Info you want to call the method. I lost really lot of time searching for this. By the way in office 2003 the PIA work good, you don't have to do the copy you have told, in Office XP there is this problem.
Thanks a lot
From Greece:
Dimitris Iliopoulos
dimilio@yahoo.com
|
|
|
|
|
How is it possible to control the Master, the Wave and the Line-In mixer controls directly?
Help!
----------------------
I think war is a dangerous place.
George W. Bush - Washington DC, May 7th 2003
|
|
|
|
|
Try looking at using DirectX as a starter. You can do some great things with it.
Yes, I program in VB6, but only because I use it to fill my addiction to having a dry place to sleep and food to eat!
|
|
|
|
|
I have a dataset that is populated from an access database and displayed in a datagrid just fine. Then I added a button to the form for updating the database.
Here is the code for the button.
private void bntStUp_Click(object sender, System.EventArgs e)
{
int iRetVal = 0;
try
{
oDS.AcceptChanges();
iRetVal = myAdapter.Update(oDS, "tblSteps");
MessageBox.Show("The update was successful. Rows Updated: " + iRetVal.ToString());
}
catch (Exception ex)
{
// Display information about update errors.
MessageBox.Show("Update Failed: " + ex.Message);
}
}
It works fine the dataset and datagrid are updated, but the database is not updated. Is there something that I am missing?
Huh?
|
|
|
|
|
Because you're calling AcceptChanges . This removes all the change information and the DataAdapter will find none, thus it will not update the database. Just call DataAdapter.Update , which will accept changes when the database has been updated. Read the documentation on the AcceptChanges method (defined on both the DataSet and DataTable classes) in the .NET Framework SDK for more information.
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
I take the AcceptChanges line of code and I get this error.
"Update requires a valid UpdateCommand when passed DataRow collection with modified rows."
Now what?
Huh?
|
|
|
|
|
It should be obvious: you need to assign a command (like a SqlCommand , OleDbCommand , or whatever is appropriate) to the DataAdapter.UpdateCommand property, using whichever DataAdapter is appropriate. How do you expect the DataAdapter to update the database if it doesn't know how to update the database?
If you use a simple SELECT statement, then you can also use a command builder like the SqlCommandBuilder to build the INSERT, UPDATE, and DELETE statements for a DataAdapter . See the .NET Framework SDK documentation for more details.
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
Thanks I will look at that.
Huh?
|
|
|
|
|
How can I programmatically push a toolbar button?
foreach (ToolBarButton refBtn in toolBar1.Buttons)
{
if refBtn meets some condition then click it. Just like a mouse click.
refBtn = left moust click;
}
thanks
|
|
|
|
|
If the ToolBar.ButtonClick event handler is accessible (i.e., in the same class or with an access modifier that allows it to be access from outside your class), then just call it like so:
public class MyForm : Form
{
private ToolBar tb;
public MyForm()
{
tb = new ToolBar();
Controls.Add(tb);
tb.ButtonClick += new ToolBarButtonClickEventHandler(tb_ButtonClick);
}
private void tb_ButtonClick(object sender, ToolBarButtonClickEventArgs e)
{
}
public void ClickButton(ToolBarButton b)
{
tb_ButtonClick(tb, new ToolBarButtonClickEventArgs(b));
}
} Otherwise, you'll have to P/Invoke the SendMessage API and send the TB_PRESSBUTTON message like so:
[DllImport("user32.dll")]
private static extern IntPtr SendMessage(
IntPtr hWnd,
uint msg,
IntPtr buttonID,
IntPtr press);
public void ClickButton(ToolBar tb, int position)
{
if (tb != null)
{
SendMessage(tb.Handle, 0x0403, new IntPtr(position), new IntPtr(1));
SendMessage(tb.Handle, 0x0403, new IntPtr(position), new IntPtr(0));
}
} See the Platform SDK documentation for the TB_PRESSBUTTON message for more information.
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
That was a fantastic answer!
thank you
|
|
|
|
|
I was wondering if anybody knows how to disable the version auto increment feature in Visual C# .NET???
|
|
|
|
|
Get rid of the asterisk in the AssemblyVersionAttribute typically found in the AssemblyInfo.cs file and use your own 4-digit versioning scheme. This is best for larger solutions anyway. We have our own scheme we used that I designed for the ~60-project solution I maintain. Especially with late-binding, automatic version is a real pain.
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
I tried that and set the version to 1.0.1.1 and when I built it it still incremented. Any ideas?
Heath Stewart wrote:
We have our own scheme we used that I designed for the ~60-project solution I maintain.
Would it be possible for you to share this system?
|
|
|
|
|
Something else is wrong, then. So long as you have something like this:
[assembly: AssemblyVersion("1.0.1.1")] You'll never have an incremental version number (and it's technically not incremental - see the attribute documentation in the .NET SDK). Also make sure that if you use the AssemblyFileVersionAttribute that you fix that as well, although I don't think that accepts an asterisk.
Make sure that you have project references as well instead of assembly references (when you add a reference, click the Project tab instead of selecting an assembly) and make sure that you have one and only one AssemblyVersionAttribute defined at the assembly level (prefixed with assembly: ). You shouldn't have any problems. If you do, you have something wrong.
And, no, I can't share that system. It's our flagship product.
If you want the versioning system I use, it's almost the same as what the C# compiler uses. The major and minor versions (the first two) you set. The third is the number of days since January 1, 2000, and the last is incremented to signify minor changes. We don't change that number much except for minor bug fixes since Fusion requires that a new assembly version exists or it won't download it (we use touchless-deployment over the 'net). The build is typically the number of days from 1/1/2000 till the target release date so that we don't change it ever day.
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
Hey Guys,
If I have created an App.config file in my project, and in that file specified a key and a value. Then coded the following :
string test1 = System.Configuration.ConfigurationSettings.AppSettings["Key1"];
tabPage1.Text = test1;
This sets the Text Property at the top of the Tab Page on start up to what i specified in the config file. Now i want to change the BackColor property of the Tab Page, but i constantly get the following error: Cannot implicitly convert type 'string' to 'System.Drawing.Color' ? Any assistance appreciated.
|
|
|
|
|
You must use the ColorConverter to covert the string to a color, like so:
Color c = this.BackColor;
string color = ConfigurationSettings.AppSettings["BackColor"];
if (color != null)
{
TypeConverter converter = TypeDescriptor.GetConverter(typeof(Color));
try
{
c = (Color)converter.ConvertFromString(color);
}
catch { }
} You can also use the AppSettingsReader , but this is limited to reading types with a Parse method:
AppSettingsReader reader = new AppSettingsReader();
bool b = (bool)reader.GetValue("ShowInTaskbar", typeof(bool)); The first way I outlined is far more extensible and provides support for more types.
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
Thanks. What if I were to want to set the Alignment property of the TabControl itself ? I've gotten continuous errors with this as well.
|
|
|
|
|
Again, a TypeConverter . Use TypeDescriptor.GetConverter(typeof(TabAlignment)) to get an EnumConverter . You might want to read-up on the TypeConverter in the .NET Framework SDK.
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
Cool, i'll read up on the type converter, since im guessing if i want to set any properties that are not strings, this is what i will be doing. Thanks for your help.
|
|
|
|
|
Word of warning - not every type has an associated TypeConverter . Only those types that are attributed with or inherit the ConverterAttribute with a valid TypeConverter (or simulate this through the component model) work. Enums, primatives, and many structs support TypeCoverter s. If you need something more encompassing, then forget about using the <appSettings> section and use a serialization approach, like using XML Serialization (see the System.Xml.Serialization namespace in the .NET Framework sDK). There are many articles here on CodeProject that discuss such an alternative. You could even create your own .config section and use XML Serialization to deserialize more complex types that may or may not have a TypeConverter associated with them. Just search this site for examples.
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
Can you group sections in a config file, such as
<configuration>
<appsettings>
<add key="LabelColor" value="Red">
<add key="LabelText" value="Test text">
|
|
|
|
|
Sorry, forgot to click the Do not treat <'s as HTML tags
<configuration>
<appsettings>
<add key="LabelColor" value="Red">
|
|
|
|