|
or you explaining or selling. Twain coms are easy to use anyhow.
I'm not an expert yet, but I play one at work. Yeah and here too.
|
|
|
|
|
i am trying to write dg tablestyle grid column widths to the registry:
opening and creating keys is just fine, i can open regedit and see the keys.
it is when i try to assign a key value to the width of a column that i get the errors.
here is how i save the key:
<br />
Param.SetValue("IHDetailIDWidth",this.dgIssueHistory.TableStyles["IssueHistory"].GridColumnStyles["DetailID"].Width);<br />
and here is how i am trying to retrieve the key:
<br />
int ID = Param.GetValue("IHDetailIDWidth");<br />
when i don't run the second line of code, i get no errors, and it is writting to the registry just fine.
when i try to run the code to retrieve the values is when i get this error: Object reference not set to an instance of an object.
it highlights the section of code where i set the value though.
any ideas on what i'm doing wrong?
|
|
|
|
|
mikemilano wrote:
when i try to run the code to retrieve the values is when i get this error: Object reference not set to an instance of an object.
Are you creating your Param object before you call the GetValues() method?
For example:
MyAppSettings Param = new MyAppSettings();
...
Param.GetValue("IHDetailIDWidth");
Also, check in your GetValue methods code to make sure all objects referenced have been created.
Roger Stewart
"I Owe, I Owe, it's off to work I go..."
|
|
|
|
|
i am creating a Param object before i call GetValues()
here's a little more of the code with the 2 methods i'm using.
I can comment out either one of the 'problem' lines, and the methods work fine, but it is when both are not commented that i get the object error.
private void CreateStyles(DataGrid dg)
{
DataGridTableStyle style = new DataGridTableStyle();
style.MappingName = "IssueHistory";
DataGridTextBoxColumn DetailID = new DataGridTextBoxColumn();
DetailID.MappingName = "DetailID";
DetailID.WidthChanged += new EventHandler(this.SaveIssueGrid);
RegistryKey softwareKey = Registry.LocalMachine.OpenSubKey("Software");
RegistryKey SC = softwareKey.OpenSubKey("SC");
if( SC != null)
{
RegistryKey Param = SC.OpenSubKey("Param");
if(Param != null)
{
DetailID.Width = (int)Param.GetValue("IHDetailIDWidth",50);
}
}
}
void SaveIssueGrid(object sender, EventArgs e)
{
RegistryKey softwareKey = Registry.LocalMachine.OpenSubKey("Software",true);
RegistryKey SC = softwareKey.CreateSubKey("SC");
RegistryKey Param = SC.CreateSubKey("Param");
Param.SetValue("IHDetailIDWidth",this.dgIssueHistory.TableStyles["IssueHistory"].GridColumnStyles["DetailID"].Width);
}
sorry for the big code post, but i've been working on this for hours with the same results.
|
|
|
|
|
Sorry for the late reply.
Since you know the keys/subkeys that you want to open, try and open/create them all at once. This gets rid of the multiple CreateSubKey/OpenSubKey statements which may be part of the problem.
I was able to get a small example working, that I hope will help you. Create a new C# Windows Application and place 2 buttons (btnRead and btnWrite), one label (label1) on the form. Add the Click events for the two buttons using the Designer Property Grid. Replace the generated Click events with the following code:
<code>
private void btnRead_Click(object sender, System.EventArgs e)
{
RegistryKey softwareKey = Registry.LocalMachine.OpenSubKey(@"Software\SC\Param");
if ( softwareKey != null )
{
int x = (int)softwareKey.GetValue("IHDetailIDWidth", 50);
label1.Text = x.ToString();
}
}
private void btnWrite_Click(object sender, System.EventArgs e)
{
RegistryKey softwareKey = Registry.LocalMachine.OpenSubKey(@"Software\SC\Param", true);
softwareKey.SetValue("IHDetailIDWidth",this.Width);
}
</code>
Roger Stewart
"I Owe, I Owe, it's off to work I go..."
|
|
|
|
|
thanks for the help .. this has made me realize my problem is in the event handler and not specific to the registry.
that is a great shortcut for just opening one key. i wasn't aware you could do it that way.
i do appreciate the help, .. i'll start a new thread on the new subject.
|
|
|
|
|
Hello!
I tried, but I don't know why I failed, I think it should be quite simple ...
Could anybody pleas help me ...
I try to make a screenshot of a window and put it in a picturebox in my program. Anybody here who can help me? (the handle of this window is known)
thx
|
|
|
|
|
I have a document in excel with several sheets, But I would like to build a listbox with the list of these sheets (more interactive).
Thank in advance.
bye
-=zoltx=-
|
|
|
|
|
|
I look for the equivalence for c# in ADO.NET. I can t find that. Could you help me ?
-=zoltx=-
|
|
|
|
|
I would like to write the width of a cell in a datagrid to the registry when a user changes the size.
I'm using a TableStyle to customize this DataGrid. ( just from the code, not the gui )
I have a method named: SaveSettings() which writes the current width of the datagrid cells to the registry.
The problem is that I can not figure out how to trigger this method.
Here is how I setup my dg column .. can someone help me with a way to trigger a method on change of the width of this column?
<br />
DataGridTextBoxColumn DetailID = new DataGridTextBoxColumn();<br />
DetailID.HeaderText = "Detail ID";<br />
DetailID.MappingName = "DetailID";<br />
DetailID.Width = 50;<br />
DetailID.WidthChanged
Thanks in advance.
|
|
|
|
|
DetailID.WidthChanged += new EventHandler(MyIDColumnWidthChanged);<br />
Then write the method body for MyIDColumnWidthChanged .
See Consuming Events[^] for further help on hooking up the event.
Roger Stewart
"I Owe, I Owe, it's off to work I go..."
|
|
|
|
|
Thank You very much. It works great! Would not have been able to do it without the consuming events link also =)
|
|
|
|
|
Hello,
Anybody knows if you can profile (func timing, func counting, etc) as it is possible to do with Visual Studio on the C++ language?
I did check the .NET profile options added at the performance monitor but they don't seem to me siutable for my needs.
Thanks a lot,
Alberto Bencivenni
www.devDept.com
|
|
|
|
|
|
Also look at compuware devpartner profiler. They had a free demo as well.
|
|
|
|
|
Leppie,
Wonderful!
The link is: http://www.red-gate.com/code_profiling.htm
I am dowloading the evaluation.
Thanks a lot,
Alberto
Alberto Bencivenni
www.devDept.com
|
|
|
|
|
Hello
I am trying to create a connection string without hardcoding the Data Source
Path like this
strConn += " Data Source=C:\\xxx\\foo.mdb;";
Currently I am trying to use something like this
strConn += " Data Source=" + Application.StartupPath + "\\foo.mdb;";
Which produces an error. What Am I doing wrong?
RL Smith
|
|
|
|
|
My advice: Change this line:
strConn += " Data Source=" + Application.StartupPath + "\\foo.mdb;";
To this:
strConn += " Data Source=" + Path.Combine(Application.StartupPath, "foo.mdb") + ";";
And as another point, you should probably use the System.Text.StringBuilder class instead of just concatenating strings. So then you would do something like this:
StringBuilder sb = new StringBuilder();
sb.AppendFormat(" Data Source={0};", Path.Combine(Application.StartupPath, "foo.mdb"));
That'll replace the {0} with the path to your mdb file. And the best part is that you can have as many parameters as you want. I would definitely read up on the StringBuilder class if I were you. It's a much more efficient way of creating strings that need to be dynamic.
I passionately hate the idea of being with it, I think an artist has always to be out of step with his time.
-Orson Welles
|
|
|
|
|
Dave;
Thanks, for the help! I got it working by moving the .mdb to the debug directory.
Thanks
RL Smith
|
|
|
|
|
Hello,
I need some help with creating a word maker in Java. the user should be able to enter a list of words at least nine of them (3 x 3) grid will be formed and should be abl to grow.
an import button should be available to import a list of words from a text file into a world list which will be compared with the list of words in the grid.
a make grid button should be availabe to allow the user create the grid after the letters have been entered.
a make word button should also be available for the user to click and search for the words in the grid. the words can be found diagonally, horizontally and vertically.
if i could get some help on how to do this i'll be very greatful thanx.
Tony
|
|
|
|
|
Mmm, this sounds awfully like you're asking us to do your homework for you. It seems to me that you'd get the most benefit from solving it yourself.
Plus, there's a slight problem in that this is a C# message board, and not a java one.
Anyway, very high level. For the word list, arrange to have the words one per line in a text file. Use Java's standard text file IO to read the file, and use a hash table (or string dictionary, or symbol table, or whatever it's called in java-land). By using such a collection class, you'll get fast lookups of possible words (if found, the word exists, if not, the word doesn't).
For the letter grid problem (that is, finding our all possible letter sequences without repeating a letter), I would look into network or graph algorithms. It sounds like a depth first search might do you best.
For each letter sequence you find, look it up in your hash table.
Cheers, Julian
Program Manager, C#
This posting is provided "AS IS" with no warranties, and confers no rights.
|
|
|
|
|
Julian Bucknall [MSFT] wrote:
Mmm, this sounds awfully like you're asking us to do your homework for you. It seems to me that you'd get the most benefit from solving it yourself.
Plus, there's a slight problem in that this is a C# message board, and not a java one.
Anyway, very high level. For the word list, arrange to have the words one per line in a text file. Use Java's standard text file IO to read the file, and use a hash table (or string dictionary, or symbol table, or whatever it's called in java-land). By using such a collection class, you'll get fast lookups of possible words (if found, the word exists, if not, the word doesn't).
For the letter grid problem (that is, finding our all possible letter sequences without repeating a letter), I would look into network or graph algorithms. It sounds like a depth first search might do you best.
For each letter sequence you find, look it up in your hash table.
Not bad julian
Dont forget to use a BufferedReader and BufferedWriter class to read the files.
use the hastable collection for searching
the Iterator class to step through since Enumerators are horrible
For the grid I would use a JTable, you are using Swing right. You can use AWT but ( its faster ) but involves a deeper understanding of the Java API which I doubt you have.
Study grid layouts and you would have to encompass it all in a Jframe. Use the IO library for the file reading. A buffered Reader makes it easy.
Other questions, please direct them to They can help more with your homework!
nick
I'm not an expert yet, but I play one at work. Yeah and here too.
|
|
|
|
|
Hi, friends.
I would like to add a ComboBox(like DropDown mode) in ToolBar.
As the default DropDown mode of ToolBar button doesn't allow user to type anything. So I wander any method I can do this. Or some properties I can set inside toolBar?
If you know any articles related to this, could you tell me, Or give me some examples.
Thank you.
|
|
|
|
|
There are quite a few examples of container ToolBars online, but the CommandBar control by Lutz Roeder is the cleanest implementation I've seen:
http://www.aisto.com/roeder/dotnet/[^]
|
|
|
|