|
I really wanna learn more.
|
|
|
|
|
Hello,
I have 2 datagridviews, DGV1 and DGV2.
I need to make "dynamic interaction" between them, what I mean is the following:
when I am clicking on specific row in DGV1 I need to highlight correspondant row in DGV2. Until here everything works fine.
But in addition, I need the vice-versa:when I am clicking on specific row in DGV2 I need to highlight correspondant row in DGV1.
I am using DGV1_CellEnter and DGV2_CellEnter events
The problem is that I got error that each one call to the other (loop).
I can solve the problem by inserting flag but I would like to know if there is a better and elegant way.
Thank you
Shay Noy
|
|
|
|
|
Short answer, check to see whether the selection of the grid you're working with matches the other selection before changing it. That way, only one update will occurr.
|
|
|
|
|
Can you please be more explicit. Thank you
Shay Noy
|
|
|
|
|
Hi,
I'm currently working on a program where I have very big Integer array - with 81000000 elements.
I want to keep this array and the information within for future work, is there a way to save that
big array in file, and then to restore the array from that file?
Thank you in advance!
|
|
|
|
|
You can do that using serialization. There are classes available in .Net to serialize an object and save it to files. You can use them.
It's not necessary to be so stupid, either, but people manage it. - Christian Graus, 2009 AD
|
|
|
|
|
Thank You for the fast answer! I solve the problem and now I can save and open the array in binary file format!
|
|
|
|
|
Welcome
It's not necessary to be so stupid, either, but people manage it. - Christian Graus, 2009 AD
|
|
|
|
|
Hi all,
using vb.net, i like to handle changes done by the user in the system control panel.
Example: In case user changes Date / Time settings i like to use the new settings i a running vb.net application.
What I have done is:
Public Sub New()<br />
MyBase.New()<br />
<br />
'This call is required by the Windows Form Designer.<br />
InitializeComponent()<br />
<br />
'Set the SystemEvents class to receive event notification <br />
'when a user preference changes, the palette changes, or <br />
'when display settings change.<br />
AddHandler SystemEvents.UserPreferenceChanging, AddressOf SystemEvents_UserPreferenceChanging<br />
<br />
End Sub<br />
<br />
<br />
Private Sub SystemEvents_UserPreferenceChanging(ByVal sender As Object, ByVal e As UserPreferenceChangingEventArgs)<br />
MessageBox.Show("UserPreferenceChanging: " & e.Category.ToString())<br />
End Sub<br />
So i get a event in case of changes in the system control panel. This works.
Using the new settings from the control panel i can adjust the frontend and/or change the current culture settings.
But how is it now possible to read the current system settings for date and time ??????
Any comments pls.?!
regards,
bauer
|
|
|
|
|
DateTime.Now will give you the value.
It's not necessary to be so stupid, either, but people manage it. - Christian Graus, 2009 AD
|
|
|
|
|
No, this does not help.
What I like to do is:
VB.NET Applications starts and does some output for Date/Time Values using the current culture settings. This works, data format is englisch, german ...... No Problem.
Now the user changes the date/time format in the windows system control panel from english to german for example.
How to handle this change in the running vb.net application? I like to adjust the output of date/time fields to the new settings of the control panel.
regards,
bauer
|
|
|
|
|
Sory. Misread your question. ToSring method for a DateTime object has an overload that takes in CultureInfo. If you pass CurrentThread.CurrentCulture to it, I believe it would work.
It's not necessary to be so stupid, either, but people manage it. - Christian Graus, 2009 AD
|
|
|
|
|
Thank you for your answer.
This does not work, because if you change the windows culture (windows control panel) the Thread Culture in the running vb.net program does not change.
|
|
|
|
|
Just make sure you are calling CurrentCulture.ClearCachedData() method everytime before you access current culture. That will give the latest information.
It's not necessary to be so stupid, either, but people manage it. - Christian Graus, 2009 AD
|
|
|
|
|
d@nish,
yes, perfect. I didn't see the methode ClearCachedData. Thank you.
So complete coding is as follows. If the event is triggered for new settings in the windows control panel the Cached Info in the culture objects in cleared and a new transfer occurs from the datavariables to the frontend.
Imports System
Imports Microsoft.Win32
Imports System.Windows.Forms
Public Class Form1
Public Sub New()
MyBase.New()
'This call is required by the Windows Form Designer.
InitializeComponent()
'Adds Handler to receive Events for any changes in the windows control panel
AddHandler SystemEvents.UserPreferenceChanging, AddressOf SystemEvents_UserPreferenceChanging
End Sub
Private Sub Form1_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
Me.PutDataToUI()
End Sub
Private Sub SystemEvents_UserPreferenceChanging(ByVal sender As Object, ByVal e As UserPreferenceChangingEventArgs)
If e.Category = UserPreferenceCategory.Locale Then
My.Application.Culture.ClearCachedData()
My.Application.UICulture.ClearCachedData()
Me.PutDataToUI()
Else
End If
End Sub
''' <summary>
''' Puts some data to an textbox
''' </summary>
''' <remarks></remarks>
Private Sub PutDataToUI()
Me.TextBox1.Text = My.Application.Culture.DisplayName & vbCrLf _
& My.Application.Culture.EnglishName & vbCrLf _
& Now.ToLongDateString & vbCrLf _
& Now.ToLongTimeString & vbCrLf _
& Now.ToShortDateString & vbCrLf _
& Now.ToShortTimeString & vbCrLf _
& My.Application.Culture.Name & vbCrLf _
& My.Application.UICulture.NativeName
End Sub
End Class
My be coding helps anybody.
regards,
bauer
|
|
|
|
|
gilchinger wrote: This does not work, because if you change the windows culture (windows control panel) the Thread Culture in the running vb.net program does not change.
A good thing, actually; imagine you displaying a monetary value, and say the cultural settings would give you a dollar-sign as the monetary unit. The value displayed is '10';
"$ 10.00"
Now you change your settings to Dutch. If the format were applied blindly, the control would show the same value in the new format;
"€ 10,00"
That's the same value, but not the same amount
I guess that the new information is stored in the Registry. Open RegEdit and explore this key;
HKEY_CURRENT_USER\Control Panel\International
I are Troll
|
|
|
|
|
Eddy,
of course, I agree.
A coding like this
Dim x As Double = 5000
Me.TextBox1.Text = x.ToString("C", My.Application.Culture.NumberFormat)
with blindly transfer to the new format is absulutly nonsense.
Option (1): adjust the amount before transfering to the new format
Option (2): Donn't use coding like mentioned above. Use always dollar, euro....,
I use option(2).
Only for date/time formats i use automatic adjustment to the new format.
|
|
|
|
|
gilchinger wrote: Only for date/time formats i use automatic adjustment to the new format.
I tend to store DateTime in GMT[^]. That would be overkill though if you're always in the same timezone.
The same goes for currency-conversions, or any other value that depends on a unit of measurement.
I are Troll
|
|
|
|
|
Hi guys im using vb.net. I've got two forms and ON LOAD of form1 i want form2 to automatically show with form1 hideing
i have already tried me.hide and my.forms.form2.show howver this doesn't work
any ideas??
Dan
|
|
|
|
|
You want to close thie first form or hide it? Anyways, create an object of form2 and then call show. From what you have posted, I assume you are treating it as a static method.
By the way, if you are hiding/closing the form1 in its load itself, why do you even need it?
It's not necessary to be so stupid, either, but people manage it. - Christian Graus, 2009 AD
|
|
|
|
|
its part of a assignment however i need form1 to close. you mention create an object of form 2 could you explain that please. Im a bit of a novice programmer
Cheers
|
|
|
|
|
Form2 frm = new Form2();
frm.Show();
That is the C# version of what I was telling.
It's not necessary to be so stupid, either, but people manage it. - Christian Graus, 2009 AD
|
|
|
|
|
found out how to do it on vb.net by using
form2 = new form2
form2.show
this shows no errors at first but when run it says
property can only be set to nothing?
is this the easiest way to do this, all i need to do is hide a form automatically when it appears. I would have thought that me.hide would have worked but for some stupid reason it dont??????
|
|
|
|
|
offroaderdan wrote: form2 = new form2
Nope. It should be dim frm as Form2 in VB.
It's not necessary to be so stupid, either, but people manage it. - Christian Graus, 2009 AD
|
|
|
|
|
You cannot hide the form in the Load event of a form. When Load is raised and the code is executed, the form is not being shown yet. After your Load event code executes, the form is shown. You can only have a form hide itself AFTER the Load hander code executes.
|
|
|
|